2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -6,7 +6,3 @@ fractran fracts n = n :
case find (\f -> n `mod` denominator f == 0) fracts of
Nothing -> []
Just f -> fractran fracts $ truncate (fromIntegral n * f)
main :: IO ()
main = print $ take 15 $ fractran [17%91, 78%85, 19%51, 23%38, 29%33, 77%29,
95%23, 77%19, 1%17, 11%13, 13%11, 15%14, 15%2, 55%1] 2

View file

@ -0,0 +1 @@
import Data.List.Split (splitOn)

View file

@ -0,0 +1,3 @@
readProgram :: String -> [Ratio a]
readProgram = map (toFrac . splitOn "/") . splitOn ","
where toFrac [n,d] = read n % read d

View file

@ -0,0 +1 @@
import Data.Maybe (mapMaybe)

View file

@ -0,0 +1,6 @@
primes = mapMaybe log2 $ fractran prog 2
where
prog = [17 % 91, 78 % 85, 19 % 51, 23 % 38, 29 % 33
,77 % 29, 95 % 23, 77 % 19, 1 % 17, 11 % 13
,13 % 11, 15 % 14, 15 % 2, 55 % 1]
log2 = fmap (+ 1) . findIndex (== 2) . takeWhile even . iterate (`div` 2)