Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 611 Bytes

beginner_series_№_4_cockroach.md

File metadata and controls

26 lines (21 loc) · 611 Bytes

Description

The cockroach is one of the fastest insects. Write a function which takes its speed in km per hour and returns it in cm per second, rounded down to the integer (= floored).

For example:

1.08 --> 30

Note! The input is a Real number (actual type is language dependent) and is >= 0. The result should be an Integer.

My Solution

def cockroach_speed(s)
  (s * 250 / 9).floor
end

Better/Alternative solution from Codewars

def cockroach_speed(s)
  (s / 0.036).floor
end