Skip to content

Instantly share code, notes, and snippets.

@alistra
Created March 7, 2012 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alistra/1996284 to your computer and use it in GitHub Desktop.
Save alistra/1996284 to your computer and use it in GitHub Desktop.
import System.IO
digits n | n < 10 = [n]
| otherwise = let (d, m) = quotRem n 10 in (digits d) ++ [m]
r = sum . digits . fact
fact n | n < 2 = 1
| otherwise = n * fact (n-1)
main = do
hSetBuffering stdout NoBuffering
print $ filter (\(x,y) -> y == 8001) $ map (\x -> (x, r x)) [1..]
import Data.List
-- xmllint --format 2.html > 2a.html
-- then got the numbers:
-- cat 2a.html | grep '<p>'
-- cat 2a.html | grep ' <p>'
-- cat 2a.html | grep ' <p>'
-- etc. :P
list = replicate 19 1 ++ replicate 7 2 ++ replicate 4 3 ++ replicate 5 4 ++ replicate 4 5
mean = sum list / genericLength list
var = sum (map (\x -> (x - mean)^2) list) / genericLength list
stddev = sqrt var
x = 2520
freqs = map (\y -> round $ x / y) [1..900]
len = sum $ freqs
-- then tried to bisect:
-- sum $ take 40 freqs
-- sum $ take 20 freqs
-- etc :P.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment