summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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]))