fork download
  1. import Control.Monad (guard)
  2.  
  3. solutions = do
  4. a <- [1..9]
  5. b <- [a + 1..9]
  6. c <- [b + 1..9]
  7. d <- [1..9]
  8. guard $ d `notElem` [a, b, c]
  9. e <- [d + 1..9]
  10. guard $ e `notElem` [a, b, c]
  11. guard $ sum [a, b, c, d, e] == 23
  12. guard $ quotRem (a + b + c) d == (e, 0)
  13. return (a, b, c, d, e)
  14.  
  15. main = mapM_ print solutions
Success #stdin #stdout 0s 5732KB
stdin
Standard input is empty
stdout
(1,4,9,2,7)
(1,5,8,2,7)
(1,6,8,3,5)
(2,4,9,3,5)
(2,6,7,3,5)
(3,5,6,2,7)