Skip to content

Instantly share code, notes, and snippets.

@faizul14
Created November 24, 2022 11:59
Show Gist options
  • Save faizul14/d4443ed17be4bbb7d89955d6cae1ef23 to your computer and use it in GitHub Desktop.
Save faizul14/d4443ed17be4bbb7d89955d6cae1ef23 to your computer and use it in GitHub Desktop.
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