fork download
  1. import Data.IntSet(IntSet, size, insert, empty)
  2.  
  3. a :: Integer -> Int -> Integer
  4. a k 1 = 52 - k
  5. a k n = k*(a k (n-1)) + (52-k)*(a (k+1) (n-1))
  6.  
  7. s :: Int -> IntSet -> Integer
  8. s 1 xs = fromIntegral $ 52 - (size xs)
  9. s n xs = sum [ s (n-1) (insert t xs) | t <- [1..52] ]
  10.  
  11. main = do
  12. let xs = [ a 0 n | n <- [1..5] ]
  13. ys = [ s n empty | n <- [1..5] ]
  14. print xs
  15. print ys
  16. print (xs == ys)
Success #stdin #stdout 0.76s 6232KB
stdin
Standard input is empty
stdout
[52,2652,135252,6897852,351790452]
[52,2652,135252,6897852,351790452]
True