Objets/Documentation
transfert26.py
Compter les calendriers par résidu · transfert26.py
Télécharger ↓"""Count eight active ticks by cyclic composition of allowed residue triples."""
from collections import defaultdict
from functools import lru_cache
from itertools import combinations,product
import json
@lru_cache(None)
def compatible(start,a,b,c,k):
visits=sorted((6*turn+(start+side)%6,side) for side,turns in enumerate((a,b,c)) for turn in turns)
assert len(visits)==4
boundary=changes=0
for (last,old),(now,new) in zip(visits,visits[1:]):
if old!=new:
changes+=1;boundary=max(boundary+2,last+1)
if changes>k or boundary>now:return False
return boundary<=22