-
-
Save alistra/1996284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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..] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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