fork(1) download
  1. import Data.Word
  2. import Data.Array.Unboxed
  3.  
  4. crack :: Int -> [Word64]
  5. crack n = helper n 0 0
  6. where helper 0 _ acc
  7. | acc == f acc = [acc]
  8. | otherwise = []
  9. helper k n acc = concat [ helper (k-1) c (acc + ps!c) | c <- [n..9]]
  10. ps = listArray (0,9) (map (^13) [0..9]) :: UArray Int Word64
  11. f 0 = 0
  12. f a = (ps ! fromIntegral (a`mod`10)) + f (a`div`10)
  13.  
  14. main = mapM_ print (crack 15)
Success #stdin #stdout 2.13s 6244KB
stdin
Standard input is empty
stdout
0
1
564240140138