From 72b0a55c2ae0076dc3138a1c35af1bf798aa7bab Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 13 Dec 2019 09:47:32 +0100 Subject: IntCode: fix bug in address resolving introduced in infinite-mem --- 2019/IntCode.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2019/IntCode.hs b/2019/IntCode.hs index 2096bcc..8d180bf 100644 --- a/2019/IntCode.hs +++ b/2019/IntCode.hs @@ -172,7 +172,7 @@ runArray arr ptr inp offset = do resolve (Addr n) = do (_, right) <- SA.getBounds arr let n' = fromIntegral n - if n' >= right then return 0 else SA.readArray arr n' + if n' > right then return 0 else SA.readArray arr n' resolve (Imm n) = return n resolve (Rel n) = resolve (Addr (fromIntegral offset + n)) resolveAddr (Addr n) = n -- cgit v1.2.3-70-g09d2