diff --git a/day16.hs b/day16.hs index 50d8429..d272940 100644 --- a/day16.hs +++ b/day16.hs @@ -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