Atelier des rouesLaboratoire EN
Objets/Documentation

ruptures20.py

Je fournis le code pour reproduire ce calcul. ruptures20.py

Télécharger ↓
"""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)]

Lire dans son contexte

Commentaires

Les commentaires en français et en anglais sont réunis ici.

La discussion reste consultable. J’ouvrirai les participations dès que la protection antispam sera configurée.