RosettaCodeData/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-2.hs

21 lines
443 B
Haskell
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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
]