aoc2022/d11/input2.py

50 lines
1.3 KiB
Python
Raw Permalink Normal View History

2022-12-11 13:04:43 +00:00
from collections import deque
PRIMES = (13,2,7,17,5,11,3,19)
def mods(x):
return [x%i for i in PRIMES]
M = [
[
deque(mods(x) for x in [ 84, 72, 58, 51])
, lambda old: [((o%i)*(3%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 7 if x[0] else 1
,0
],[
deque(mods(x) for x in [ 88, 58, 58 ])
, lambda old: [((o%i)+(8%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 5 if x[1] else 7
,0
],[
deque(mods(x) for x in [ 93, 82, 71, 77, 83, 53, 71, 89])
, lambda old: [((o%i)*(o%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 4 if x[2] else 3
,0
],[
deque(mods(x) for x in [ 81, 68, 65, 81, 73, 77, 96])
, lambda old: [((o%i)+(2%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 6 if x[3] else 4
,0
],[
deque(mods(x) for x in [ 75, 80, 50, 73, 88])
, lambda old: [((o%i)+(3%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 0 if x[4] else 6
,0
],[
deque(mods(x) for x in [ 59, 72, 99, 87, 91, 81])
, lambda old: [((o%i)*(17%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 3 if x[5] else 2
,0
],[
deque(mods(x) for x in [ 86, 69])
, lambda old: [((o%i)+(6%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 0 if x[6] else 1
,0
],[
deque(mods(x) for x in [ 91])
, lambda old: [((o%i)+(1%i))%i for (o,i) in zip(old,PRIMES)]
, lambda x: 5 if x[7] else 2
,0
]
]