Skip to content

Instantly share code, notes, and snippets.

@Plotist
Last active December 26, 2020 21:20
Show Gist options
  • Save Plotist/ef84a7273968ced444702c33a7efaecf to your computer and use it in GitHub Desktop.
Save Plotist/ef84a7273968ced444702c33a7efaecf to your computer and use it in GitHub Desktop.
<codility> Frog Jump
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