From 92ed850443d1689d3abd9920a40c16a7940a5498 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 15 Dec 2019 10:59:46 +0100 Subject: Day 15 --- 2019/IntCode.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to '2019/IntCode.hs') diff --git a/2019/IntCode.hs b/2019/IntCode.hs index 8d180bf..1730dfd 100644 --- a/2019/IntCode.hs +++ b/2019/IntCode.hs @@ -2,7 +2,7 @@ module IntCode ( Arg(..), IC(..), mkAddr, mkImm, mkRel, parse, decode, run, unparse, - runInterruptible, runContinue, Continuation() + runInterruptible, runContinue, Continuation(), initialContinuation ) where import Control.Monad.ST @@ -134,6 +134,9 @@ runContinue (Continuation frozen ptr offset) moreinput = runST $ do Left cont -> return (Left (cont, snd res)) Right mem -> return (Right (mem, snd res)) +initialContinuation :: [Integer] -> Continuation +initialContinuation initMem = Continuation (A.listArray (0, length initMem - 1) initMem) 0 0 + runArray :: SA.STArray s Int Integer -> Int -> [Integer] -> Int -> ST s (Either Continuation [Integer], [Integer]) runArray arr ptr inp offset = do (ic, len) <- decode' arr ptr -- cgit v1.2.3-70-g09d2