diff --git a/2019/day9/Intcode.hs b/2019/day9/Intcode.hs index 8f93ae5..a7122f8 100644 --- a/2019/day9/Intcode.hs +++ b/2019/day9/Intcode.hs @@ -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 diff --git a/2019/day9/day9.hs b/2019/day9/day9.hs index 7e76175..71d7489 100644 --- a/2019/day9/day9.hs +++ b/2019/day9/day9.hs @@ -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