Project Euler Problem 038
import Data.List build :: (Enum a, Num a, Show a) => a -> String build n = imp r "" where r :: [String] r = map show (n:map (*n) [2..]) imp :: [String] -> String -> String imp [] acc = acc imp (x:xs) acc | (length acc) < 9 = imp xs (acc++x) imp (_:_) acc | otherwise = acc ispan :: [Char] -> Bool ispan n = (length n) == 9 && (nub $ sort $ n)=="123456789" ansl :: String ansl = maximum [r | x<-[1..9999::Integer],let r=build x,ispan r] -- "932718654" main :: IO () main = print ansl