From bfb1ae0d73332b70e7cfbd67e54e35e7441ef4c7 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Wed, 27 Nov 2024 06:38:22 +0100 Subject: [PATCH] Updated 2017/18 --- 2017/18/solution.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/2017/18/solution.py b/2017/18/solution.py index 24287f3..d2d0663 100644 --- a/2017/18/solution.py +++ b/2017/18/solution.py @@ -43,30 +43,41 @@ if part == 1: print(i) if i[0] == 'set': - sets[i[1]] = i[2] + if isinstance(i[2], str): + sets[i[1]] = int(i[2]) + else: + sets[i[1]] = int(sets[i[2]]) + x += 1 elif i[0] == 'add': sets[i[1]] = int(sets[i[1]]) + int(i[2]) + x += 1 elif i[0] == 'mul': if i[2] in sets: sets[i[1]] = int(sets[i[1]]) * int(sets[i[2]]) else: sets[i[1]] = int(sets[i[1]]) * int(i[2]) + x += 1 elif i[0] == 'mod': sets[i[1]] = int(sets[i[1]]) % int(i[2]) + x += 1 elif i[0] == 'snd': last_sound = sets[i[1]] + x += 1 elif i[0] == 'rcv': if sets[i[1]] != 0: sets[i[1]] = int(sets[i[1]]) + x += 1 else: print('skipped') + x += 1 + - if i[0] == 'jgz': + elif i[0] == 'jgz': #this is the one that fails if isinstance(i[2], str): if sets[i[1]] > 0: @@ -75,8 +86,7 @@ if part == 1: x += int(i[2]) else: x += 1 - else: - x += 1 +