RosettaCodeData/Task/Dinesmans-multiple-dwelling-problem/Haskell/dinesmans-multiple-dwelling-problem-2.hs
2019-09-12 10:33:56 -07:00

18 lines
405 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 ]