RosettaCodeData/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-2.hs
2023-07-01 13:44:08 -04:00

20 lines
443 B
Haskell

import Data.List (permutations)
main :: IO ()
main =
print
[ ( "Baker lives on " <> show b,
"Cooper lives on " <> show c,
"Fletcher lives on " <> show f,
"Miller lives on " <> show m,
"Smith lives on " <> show s
)
| [b, c, f, m, s] <- permutations [1 .. 5],
b /= 5,
c /= 1,
f /= 1,
f /= 5,
m > c,
abs (s - f) > 1,
abs (c - f) > 1
]