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 +