Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created March 10, 2019 12:27
Show Gist options
  • Save pbrewczynski/a7e47e8e703e02f8d08e169814d32045 to your computer and use it in GitHub Desktop.
Save pbrewczynski/a7e47e8e703e02f8d08e169814d32045 to your computer and use it in GitHub Desktop.
import Foundation
// Complete the kangaroo function below.
func kangaroo(x1: Int, v1: Int, x2: Int, v2: Int) -> String {
if v2 >= v1 {
return "NO"
}
let speedDifference = v1 - v2
let initialPositionDifference = x2 - x1
if (initialPositionDifference % speedDifference) == 0 {
return "YES"
} else {
return "NO"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment