Skip to content

Instantly share code, notes, and snippets.

@keitaito
Created January 31, 2017 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keitaito/4701aed3812db9b9d64d16ee155ab8af to your computer and use it in GitHub Desktop.
Save keitaito/4701aed3812db9b9d64d16ee155ab8af to your computer and use it in GitHub Desktop.
//
// HackerRankChallengeSolution-Kangaroo.swift
// Kangaroo
//
// Created by Keita Ito on 1/29/17.
// Copyright © 2017 Keita Ito. All rights reserved.
//
// https://www.hackerrank.com/challenges/kangaroo
let inputs = readLine()!.characters.split(separator: " ").map { Int(String($0))! }
var x1 = inputs[0]
var v1 = inputs[1]
let x2 = inputs[2]
let v2 = inputs[3]
if v2 > v1 || v2 == v1 {
print("NO")
} else {
if (x1 - x2) % (v2 - v1) == 0 {
print("YES")
} else {
print("NO")
}
}
// https://www.hackerrank.com/challenges/kangaroo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment