September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

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

View file

@ -1 +1,2 @@
import Data.Maybe (mapMaybe)
import Data.List (elemIndex)

View file

@ -1,6 +1,20 @@
primes :: [Int]
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)
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 succ . elemIndex 2 . takeWhile even . iterate (`div` 2)