Skip to content

Instantly share code, notes, and snippets.

@ane
Created September 20, 2010 08:52
Show Gist options
  • Save ane/587630 to your computer and use it in GitHub Desktop.
Save ane/587630 to your computer and use it in GitHub Desktop.
module Main where
import Data.List
magic :: Int -> Int -> Int
magic end c = foldr1 (+) (counted [1 .. end])
where
counted list = map findN list
findN x = length . filter (\l -> length l == c) . group . sort . filter (/= 0) . map (\z -> z `mod` 10) . take 5 . iterate (\y -> y `div` 10) $ x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment