Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solution(x, y, d)
- position = x
- positions = []
- until position >= y
- position += d
- positions << position
- end
- return positions.length
- end
- def solution(x, y, d)
- (y - x).fdiv(d).ceil
- end
- def solution(x, y, d)
- jumps = (y - x) / d.to_f
- jumps.ceil
- end
- def solution(x, y, d)
- jumps = 0
- until x >= y
- x += d
- jumps += 1
- end
- jumps
- end
- def solution(start_position, end_position, jump_distance)
- delta_space = end_position - start_position
- return (delta_space.to_f / jump_distance).ceil
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement