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