From e9a6550480149fa4102646f025c9c7eefab7f66b Mon Sep 17 00:00:00 2001 From: Arranun Date: Thu, 5 Dec 2019 23:40:54 +0100 Subject: [PATCH] Day5: Part1 works --- day5.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/day5.hs b/day5.hs index fbaa606..c8da4de 100644 --- a/day5.hs +++ b/day5.hs @@ -2,8 +2,8 @@ import Data.List.Split import Data.Char as Char main = do - let content = [1002,4,3,4,33] - let input = [] + content <- getList <$> getContents + let input = [1] let output = operation content content 0 input [] mapM putStrLn (map show output) @@ -33,7 +33,7 @@ compute (op:x:y:z:_) state index input output= operation :: [Int] -> [Int] -> Int -> [Int] -> [Int] -> [Int] operation (99:_) state index input output = - state + output operation (op:x:y:z:_) state index input output | last (digits op) == 1 = do let newindex = index + 4 @@ -74,7 +74,7 @@ put(op1:op2:m1:_) p1 input state = out :: [Int] -> [Int] -> Int -> [Int] -> [Int] out (op1:op2:m1:_) output p1 state = - output ++ [(state !! (getValue m1 p1 state))] + output ++ [(getValue m1 p1 state)] insert :: [Int] -> Int -> Int -> [Int] insert xs value index = do