Created
May 5, 2023 13:48
-
-
Save iafsilva/63f3f3d2c4d8d18567340f343f34fa96 to your computer and use it in GitHub Desktop.
FrogJmp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun solution(x: Int, y: Int, d: Int): Int { | |
val distance = y - x | |
val jumps = distance / d | |
// If the jumps are 1.1, that means 2 jumps. | |
return if (distance % d == 0) jumps else jumps + 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment