From e8070b262061e6ae080c3255a489c12d51250087 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 19 Dec 2019 14:32:26 +0100 Subject: Fix memory initialisation bug in intcode --- 2019/IntCode.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2019/IntCode.hs b/2019/IntCode.hs index 1730dfd..0729e0f 100644 --- a/2019/IntCode.hs +++ b/2019/IntCode.hs @@ -149,7 +149,7 @@ runArray arr ptr inp offset = do (_, right) <- SA.getBounds arr1 if idx < right then return arr1 - else SA.getElems arr1 >>= \els -> SA.newListArray (0, 2 * idx) (els ++ replicate (idx - right + 1) 0) + else SA.getElems arr1 >>= \els -> SA.newListArray (0, 2 * idx) (els ++ replicate (2 * idx - right) 0) performWrite arr1 idx value = do arr' <- resize arr1 (fromIntegral idx) SA.writeArray arr' (fromIntegral idx) value -- cgit v1.2.3-70-g09d2