loading...

Discussion on: Daily Challenge #83 - Deodorant Evaporator

Collapse
aminnairi profile image
Amin

Elm

getDaysBeforeEvaporation : Float -> Float -> Int
getDaysBeforeEvaporation percentageBeforeUnusable percentageLostPerDay =
    let
        percentageBeforeUnusableClamped : Float
        percentageBeforeUnusableClamped =
            percentageBeforeUnusable
                |> clamp 1 100

        percentageLostPerDayClamped : Float
        percentageLostPerDayClamped =
            percentageLostPerDay
                |> clamp 1 100
    in
    floor <| (100 - percentageBeforeUnusableClamped) / percentageLostPerDayClamped

Playground

Try it online here.