loading...

Discussion on: Daily Challenge #83 - Deodorant Evaporator

Collapse
pmkroeker profile image
Peter

In Go! This assumes that the evaporator is always filled up to 100%.

func evaporator(evapPerDay, threshold float64) int {
    days := 0
    fill := 100.0
    for fill >= threshold {
        days += 1
        fill -= (fill * evapPerDay / 100)
    }
    return days
}

Go Playground Example

EDIT:
Forgot to take consider that the evapPerDay is based on the current fill not the starting.