나는 이렇게 학습한다/Algorithm & SQL

1026. Beginner Series #4 Cockroach

daco2020 2022. 10. 26. 21:14
반응형

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.



Solution:

def cockroach_speed(s):
    import math
    return math.floor(km_to_cm(s) / hour_to_seconds(1))

def km_to_cm(km):
    return km * 100000

def hour_to_seconds(hour):
    return hour * 3600


반응형