Last active
December 26, 2020 21:20
-
-
Save Plotist/ef84a7273968ced444702c33a7efaecf to your computer and use it in GitHub Desktop.
<codility> Frog Jump
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
def solution(x, y, d) | |
raise ArgumentError.new( | |
"Invalid argument type" | |
) if !x.is_a?(Integer) || !y.is_a?(Integer) | |
raise ArgumentError.new( | |
"y should be less or equal to 1 000 000 000" | |
) if y > 1000000000 | |
raise ArgumentError.new( | |
"x should be less then y and greater then 0" | |
) if x > y || x < 1 | |
((y - x) / d*1.0).ceil | |
end | |
p solution(10, 85, 30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment