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

Deodorant Evaporator

daco2020 2022. 8. 22. 23:42
반응형

This program tests the life of an evaporator containing a gas.

We know the content of the evaporator (content in ml), the percentage of foam or gas lost every day (evap_per_day) and the threshold (threshold) in percentage beyond which the evaporator is no longer useful. All numbers are strictly positive.

The program reports the nth day (as an integer) on which the evaporator will be out of use.

Example:

evaporator(10, 10, 5) -> 29

Note:

Content is in fact not necessary in the body of the function "evaporator", you can use it or not use it, as you wish. Some people might prefer to reason with content, some other with percentages only. It's up to you but you must keep it as a parameter because the tests have it as an argument.

 

 

Solution:

def evaporator(content, evap_per_day, threshold):
    count = 0
    content = 100
    per = evap_per_day/100
    while content > threshold:
        count += 1
        content -= content * per
    return count

 

 

반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

0824. N-th Power  (0) 2022.08.24
Alternate capitalization  (0) 2022.08.23
Sum of Minimums!  (0) 2022.08.21
Flatten and sort an array  (0) 2022.08.20
Find the stray number  (0) 2022.08.19