This commit is contained in:
DUEFON 2022-12-11 23:00:28 +01:00
parent cff00ffb8b
commit 14b50a045b
1 changed files with 3 additions and 3 deletions

View File

@ -4,10 +4,9 @@ from useful import *
def monkey(p):
ls = p.strip().split('\n')
op = ls[2].strip().split()[4]
return [op, *[numbers(l) for l in ls[1:3]], *[numbers(l)[0] for l in ls[3:]]]
return [op, *[numbers(l) for l in ls[1:3]], *[numbers(l)[0] for l in ls[3:]], 0]
ms = [monkey(p) for p in pgphs(open(0).read())]
ic(ms)
def op(base, leop, vals):
if not vals: # happens once in our input; is 'old * old'
@ -17,6 +16,7 @@ def op(base, leop, vals):
def rnd():
for m in ms:
a = m[1]
m[6] += len(a)
for i in a:
i = op(i, m[0], m[2]) // 3
ms[m[4 if not (i % m[3]) else 5]][1].append(i)
@ -25,4 +25,4 @@ def rnd():
for i in range(20):
rnd()
ic(ms)
print(reduce(lambda a, b: a * b, sorted(m[6] for m in ms)[-2:]))