Atelier des rouesLab FR
Objects/Documentation

sejour32.py

When spacing guarantees the dwell · sejour32.py

Download ↓
"""Earliest cuts versus slot-by-slot dynamic programming, including interior obstructions."""
from itertools import combinations,product
import json
def cuts(visits,N,d,pad=False):
    shift=d if pad else 0;end=N+2*shift
    last=0;path=[]
    for (a,x),(b,y) in zip(visits,visits[1:]):
        if x==y:continue
        last=max(last+d,a+shift+1)
        if last>b+shift:return None
        path.append(last-shift)
    return path if end-last>=d else None
def automaton(visits,N,d):
    fixed=dict(visits);states={(x,0) for x in range(3)}
    for i in range(N):
        choices=(fixed[i],) if i in fixed else range(3)

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.