summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2022-12-21 18:55:23 +0000
committerTomasz Kramkowski <tomasz@kramkow.ski>2022-12-21 18:55:23 +0000
commit8844cd29f12a12e3891dbdc06b04e283b48040c7 (patch)
treef062b36ebf9f10a54dd3481897529eca6d7bca9c
parentb30f6554b7e9ceba6ea3768e9aa6eb0fbd02411b (diff)
downloadaoc2022-8844cd29f12a12e3891dbdc06b04e283b48040c7.tar.gz
aoc2022-8844cd29f12a12e3891dbdc06b04e283b48040c7.tar.xz
aoc2022-8844cd29f12a12e3891dbdc06b04e283b48040c7.zip
21 sympyHEADmaster
-rw-r--r--21.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/21.py b/21.py
index 03f94ee..40967a9 100644
--- a/21.py
+++ b/21.py
@@ -1,7 +1,7 @@
from operator import add, sub, mul, truediv, eq
from subprocess import run, PIPE
from utils import open_day
-from z3 import Int, ArithRef, solve
+from sympy import solve, Symbol
monkeys = {}
with open_day(21) as f:
@@ -12,15 +12,15 @@ with open_day(21) as f:
expr = int(expr[0])
monkeys[target] = expr
-ops = { '+': add, '-': sub, '*': mul, '/': truediv, '==': eq }
+ops = { '+': add, '-': sub, '*': mul, '/': truediv }
def eval_monkey(m):
expr = monkeys[m]
- if isinstance(expr, int) or isinstance(expr, ArithRef):
+ if isinstance(expr, int) or isinstance(expr, Symbol):
return expr
return ops[expr[1]](eval_monkey(expr[0]), eval_monkey(expr[2]))
print(int(eval_monkey('root')))
-monkeys['humn'] = Int('humn')
-monkeys['root'][1] = '=='
-solve(eval_monkey('root'))
+monkeys['humn'] = Symbol('humn')
+monkeys['root'][1] = '-'
+print(int(solve(eval_monkey('root'), monkeys['humn'])[0]))