Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.

Day16: (++) has O(n)

master
Arranun 3 years ago
parent 417c4ede04
commit 196dbbff3e

@ -2,11 +2,11 @@ import Data.Char
main = do
cont <- getContents
let content = (drop 5977377 ( concat $ replicate 10000 (map digitToInt $ init cont) ))
let test1 = doStepsP2 content 1
let content = drop 5977377 (concat (replicate 10000 (map digitToInt $ init cont) ))
let test1 = doStepsP2 content 100
putStrLn (show $ length content)
--mapM putStrLn (map show patter)
putStrLn (show $ test1)
putStrLn (show $ take 8 test1)
getPatternForIndex :: [Int] -> Int -> Int -> [Int]
getPatternForIndex patter length index = drop (1 + index) $ take (length +1) (cycle base)
@ -30,8 +30,8 @@ doSteps xs patterns cnt
stepP2 :: [Int] -> Int -> [Int] -> [Int]
stepP2 xs sumIn acc
| sumIn == 0 = acc
| sumIn > 0 = stepP2 (drop 1 xs) (sumIn - (head xs)) (acc ++ [mod sumIn 10])
| sumIn == 0 = reverse acc
| sumIn > 0 = stepP2 (drop 1 xs) (sumIn - (head xs)) ((mod sumIn 10):acc)
doStepsP2 :: [Int] -> Int ->[Int]
doStepsP2 xs cnt

Loading…
Cancel
Save