Day5: Part1 works

This commit is contained in:
Arranun 2019-12-05 23:40:54 +01:00
parent 3ebc6755af
commit e9a6550480

View File

@ -2,8 +2,8 @@ import Data.List.Split
import Data.Char as Char import Data.Char as Char
main = do main = do
let content = [1002,4,3,4,33] content <- getList <$> getContents
let input = [] let input = [1]
let output = operation content content 0 input [] let output = operation content content 0 input []
mapM putStrLn (map show output) 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 :: [Int] -> [Int] -> Int -> [Int] -> [Int] -> [Int]
operation (99:_) state index input output = operation (99:_) state index input output =
state output
operation (op:x:y:z:_) state index input output operation (op:x:y:z:_) state index input output
| last (digits op) == 1 = do | last (digits op) == 1 = do
let newindex = index + 4 let newindex = index + 4
@ -74,7 +74,7 @@ put(op1:op2:m1:_) p1 input state =
out :: [Int] -> [Int] -> Int -> [Int] -> [Int] out :: [Int] -> [Int] -> Int -> [Int] -> [Int]
out (op1:op2:m1:_) output p1 state = out (op1:op2:m1:_) output p1 state =
output ++ [(state !! (getValue m1 p1 state))] output ++ [(getValue m1 p1 state)]
insert :: [Int] -> Int -> Int -> [Int] insert :: [Int] -> Int -> Int -> [Int]
insert xs value index = do insert xs value index = do