Created
January 31, 2017 01:35
-
-
Save keitaito/4701aed3812db9b9d64d16ee155ab8af to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// 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