Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. def solution(x, y, d)
  2. position = x
  3. positions = []
  4. until position >= y
  5. position += d
  6. positions << position
  7. end
  8. return positions.length
  9.  
  10. end
  11.  
  12. def solution(x, y, d)
  13. (y - x).fdiv(d).ceil
  14. end
  15.  
  16. def solution(x, y, d)
  17. jumps = (y - x) / d.to_f
  18. jumps.ceil
  19. end
  20.  
  21. def solution(x, y, d)
  22. jumps = 0
  23. until x >= y
  24. x += d
  25. jumps += 1
  26. end
  27. jumps
  28. end
  29.  
  30. def solution(start_position, end_position, jump_distance)
  31. delta_space = end_position - start_position
  32. return (delta_space.to_f / jump_distance).ceil
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement