Project Euler Problem 079
import Data.List import System.IO.Unsafe (unsafePerformIO) perm :: Eq a => [a] -> [[a]] perm [] = [[]] perm l = [x:y | x<-l,y<-perm (delete x l) ] input :: String input = unsafePerformIO $ readFile "079keylog.txt" lists :: [Char] lists = nub $ sort $ filter (/='\n') input wordlist :: [String] wordlist = lines input check :: Eq a => [a] -> [a] -> Bool check _ [] = True check [] _ = False check (k:ks) (x:xs) | k == x = check ks xs check (_:ks) xs = check ks xs ans1 :: [Char] ans1 = head [ l | l <- perm lists,all (check l) wordlist] main :: IO () main = print ans1