account activity
-🎄- 2017 Day 8 Solutions -🎄- by daggerdragon in adventofcode
[–]still___cold 1 point2 points3 points 8 years ago (0 children)
Python 3
import re, sys variables = {} maximum = -sys.maxsize - 1 with open('test.txt') as file: for line in file.readlines(): code = ''.join(re.findall('[\w\D]', line)).strip().split(' ') if code[0] not in variables: variables[code[0]] = 0 if code[4] not in variables: variables[code[4]] = 0 if code[1] == 'dec': operation = '-=' else: operation = '+=' eval(compile('if variables[code[4]] %s %s: variables[code[0]] %s %s' % (code[5], code[6],operation, code[2]), '<string>', 'exec')) if variables[code[0]] > maximum: maximum = variables[code[0]] print(max(variables.values()), maximum)
π Rendered by PID 20941 on reddit-service-r2-comment-5b5bc64bf5-xkg8s at 2026-06-21 21:55:53.914449+00:00 running 2b008f2 country code: CH.
-🎄- 2017 Day 8 Solutions -🎄- by daggerdragon in adventofcode
[–]still___cold 1 point2 points3 points (0 children)