Guest User

Untitled

a guest
Jul 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. import Data.List
  2.  
  3. listToNum :: [Int] -> Int
  4. listToNum = foldl (\x y -> x * 10 + y) 0
  5.  
  6. valid :: [Int] -> Bool
  7. valid xs = (a * b) == c
  8. where
  9. a = listToNum (take 3 xs)
  10. b = xs !! 3
  11. c = listToNum (drop 4 xs)
  12.  
  13. main = print $ filter valid (permutations [1..8])
Add Comment
Please, Sign In to add comment