From: Neil Smith Date: Fri, 6 Dec 2019 08:26:09 +0000 (+0000) Subject: Removed some old, dead code X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=d482e7e5cd50b4b3e6e2469df30630e8eb372e49;p=advent-of-code-19.git Removed some old, dead code --- diff --git a/advent05/src/advent05.hs b/advent05/src/advent05.hs index 752b8ed..36ba499 100644 --- a/advent05/src/advent05.hs +++ b/advent05/src/advent05.hs @@ -36,17 +36,11 @@ main :: IO () main = do text <- TIO.readFile "data/advent05.txt" let mem = successfulParse text - -- let machine = makeMachine mem print $ findMachineOutput [1] mem print $ findMachineOutput [5] mem - -- print $ part2 machine --- part1 machine = (_memory $ execState runAll machine1202)!0 --- where machine1202 = machine { _memory = M.insert 1 12 $ M.insert 2 2 $ _memory machine } - - -findMachineOutput inputs program = output -- last output +findMachineOutput inputs program = last output where finalStack = runState ( runReaderT ( @@ -57,32 +51,11 @@ findMachineOutput inputs program = output -- last output (makeMachine program) ((_retval, output), _machine) = finalStack - --- part1 = nounVerbResult 12 2 - --- part2Target = 19690720 - --- part2 machine = noun * 100 + verb --- where (noun, verb) = head $ [(n, v) | n <- [0..99], v <- [0..99], --- nounVerbResult n v machine == part2Target ] - - makeMachine :: [Int] -> Machine makeMachine memory = Machine {_ip = 0, _inputIndex = 0 , _memory = M.fromList $ zip [0..] memory } --- nounVerbResult :: Int -> Int -> Machine -> Int --- nounVerbResult noun verb machine = machineOutput nvMachine --- where nvMachine0 = machineNounVerb machine noun verb --- nvMachine = execState runAll nvMachine0 - --- machineNounVerb :: Machine -> Int -> Int -> Machine --- machineNounVerb machine noun verb = machine { _memory = M.insert 1 noun $ M.insert 2 verb $ _memory machine } - --- machineOutput :: Machine -> Int --- machineOutput machine = (_memory machine)!0 - runAll :: ProgrammedMachine runAll = do mem <- gets _memory