반응형
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
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1028. Will you make it? (0) | 2022.10.29 |
---|---|
1027. Filling an array (part 1) (0) | 2022.10.28 |
1025. Exclusive "or" (xor) Logical Operator (0) | 2022.10.26 |
1024. Sum The Strings (0) | 2022.10.24 |
1023. No Loops 2 - You only need one (0) | 2022.10.23 |