fork download
  1. import Data.List
  2.  
  3. main :: IO ()
  4. main = print . sum $ filter isPan [1..9876]
  5.  
  6. isPan :: Int -> Bool
  7. isPan n = nub s == s &&
  8. or [ sort (show x ++ show y) == ['1'..'9'] \\ s
  9. | x <- [1 .. floor . sqrt $ fromIntegral n]
  10. , let (y, rest) = n `divMod` x, rest == 0
  11. ]
  12. where s = '0' : show n
Success #stdin #stdout 0.06s 3592KB
stdin
Standard input is empty
stdout
45228