summaryrefslogtreecommitdiff
path: root/2019
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-12-19 14:32:26 +0100
committertomsmeding <tom.smeding@gmail.com>2019-12-19 14:32:26 +0100
commite8070b262061e6ae080c3255a489c12d51250087 (patch)
treee183a9b13e7bbf1f06e09db1f5d5c105fb792f6a /2019
parent5644b73188deae8f1689bfca8c970c6d08d49b6c (diff)
Fix memory initialisation bug in intcode
Diffstat (limited to '2019')
-rw-r--r--2019/IntCode.hs2
1 files changed, 1 insertions, 1 deletions
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