-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkyu7_deodorant_evaporator.go
35 lines (29 loc) · 1.14 KB
/
kyu7_deodorant_evaporator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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;
//
// https://www.codewars.com/kata/5506b230a11c0aeab3000c1f
//
package kata
func Evaporator(content float64, evapPerDay int, threshold int) int {
threshold_abs := (content * float64(threshold)) / 100
days := 0
left := content
for left > threshold_abs {
left = left - (left * float64(evapPerDay)) / 100
days += 1
}
return days
}