Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -1,15 +1,15 @@
triangles :: Int -> [[Int]]
triangles max_peri | max_peri < 12 = []
| otherwise = concat tiers where
tiers = takeWhile (not.null) $ iterate tier [[3,4,5]]
tier = concatMap (filter ((<=max_peri).sum).tmul)
tmul t = map (map (sum . zipWith (*) t))
[[[ 1,-2,2],[ 2,-1,2],[ 2,-2,3]],
[[ 1, 2,2],[ 2, 1,2],[ 2, 2,3]],
[[-1, 2,2],[-2, 1,2],[-2, 2,3]]]
| otherwise = concat tiers where
tiers = takeWhile (not.null) $ iterate tier [[3,4,5]]
tier = concatMap (filter ((<=max_peri).sum).tmul)
tmul t = map (map (sum . zipWith (*) t))
[[[ 1,-2,2],[ 2,-1,2],[ 2,-2,3]],
[[ 1, 2,2],[ 2, 1,2],[ 2, 2,3]],
[[-1, 2,2],[-2, 1,2],[-2, 2,3]]]
triangle_count max_p = (length t, sum $ map ((max_p `div`).sum) t)
where t = triangles max_p
where t = triangles max_p
main = mapM_ putStrLn $
map (\n -> show n ++ " " ++ show (triangle_count n)) $ map (10^) [1..]
map (\n -> show n ++ " " ++ show (triangle_count n)) $ map (10^) [1..]