parent
b177b0daa5
commit
84bd9e7c08
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user