Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 617 Bytes

keep_hydrated.md

File metadata and controls

32 lines (24 loc) · 617 Bytes

Description

Nathan loves cycling.

Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling.

You get given the time in hours and you need to return the number of litres Nathan will drink, rounded to the smallest value.

For example:

hours = 3 ----> liters = 1
 
hours = 6.7---> liters = 3

hours = 11.8--> liters = 5

My Solution

def litres(time)
  (time/2).floor
end

Better/Alternative solution from Codewars

def litres(time)
  (time * 0.5).floor
end