Atelier des rouesLab FR
Objects/Documentation

ruptures20.py

I provide the code for this calculation. ruptures20.py

Download ↓
"""Up to two changes, at least h slots between interior change times; endpoints allowed."""
from itertools import accumulate, product
from math import lcm
import json
from decalages19 import LEFT,run as single


def solve(q,j,h):
    T=lcm(24,q)
    right={a%q for a in (0,1,4,8,9)}
    def hit(t,d,e):return int(t%24 in LEFT and (t-d-e)%q in right)
    delays=range(-j,j+1)
    rows=[]
    for d in range(q):
        prefix={e:list(accumulate((hit(t,d,e) for t in range(T)),initial=0)) for e in delays}
        front=[min((v[t],e) for e,v in prefix.items()) for t in range(T+1)]

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.