RosettaCodeData/Task/Department-numbers/Haskell/department-numbers-5.hs
2023-07-01 13:44:08 -04:00

28 lines
702 B
Haskell

-------------------- DEPARTMENT NUMBERS ------------------
options :: Int -> Int -> Int -> [(Int, Int, Int)]
options lo hi total =
( \ds ->
filter even ds
>>= \x ->
filter (/= x) ds
>>= \y ->
[total - (x + y)]
>>= \z ->
[ (x, y, z)
| y /= z && lo <= z && z <= hi
]
)
[lo .. hi]
--------------------------- TEST -------------------------
main :: IO ()
main =
let xs = options 1 7 12
in putStrLn "(Police, Sanitation, Fire)\n"
>> mapM_ print xs
>> mapM_
putStrLn
[ "\nNumber of options: ",
show (length xs)
]