import List exposing (all, sum)
import Maybe exposing (andThen, map)
isAngle : Int -> Bool
isAngle angle =
angle > 0 && angle < 180
maybeAngles : List Int -> Maybe (List Int)
maybeAngles angles =
if all isAngle angles && sum angles < 180 then
third : Int -> Int -> Maybe Int
third first second =
maybeAngles [ first, second ]
|> map (sum >> (-) 180)
Test it online
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.