Created
November 24, 2022 11:59
-
-
Save faizul14/d4443ed17be4bbb7d89955d6cae1ef23 to your computer and use it in GitHub Desktop.
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 kangaroo(x1: Int, v1: Int, x2: Int, v2: Int): String { | |
// Write your code here | |
var x1Ex = x1 | |
var v1Ex = v1 | |
var x2Ex = x2 | |
var v2Ex = v2 | |
for(i in 0..1000){ | |
if ((x1Ex + v1Ex) == (x2Ex + v2Ex)){ | |
return@kangaroo "YES" | |
}else{ | |
x1Ex = x1Ex + v1Ex | |
x2Ex = x2Ex + v2Ex | |
} | |
} | |
return "NO" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment