Day 9: Minor refactor

Motivated by Day 11
This commit is contained in:
shu 2019-12-12 15:22:20 +01:00
parent b177b0daa5
commit 84bd9e7c08
2 changed files with 10 additions and 6 deletions

View File

@ -4,6 +4,7 @@ module Intcode
, step
, tapePreprocess
, TMAction(Continue, Output, Halt)
, execSteps
) where
import Control.DeepSeq as DeepSeq
@ -138,3 +139,11 @@ step tm =
case m !! (length params - 1) of
Relative -> V.last opvec + pointerOffset tm
_ -> V.last opvec
execSteps :: TuringMachine -> TuringMachine
execSteps tm =
case state tmNew of
Continue -> execSteps tmNew
_ -> tmNew
where
tmNew = step tm

View File

@ -25,9 +25,4 @@ main = do
["Part 1: " ++ show a ++ ", Part 2: " ++ show b | a <- out1, b <- out2]
runIntcode :: TuringMachine -> TuringMachine
runIntcode tm =
case state tmNew of
Continue -> runIntcode tmNew
_ -> tmNew
where
tmNew = step tm
runIntcode = execSteps