import json
from pathlib import Path

d = json.loads(Path('starter.json').read_text())
mask = (1 << d['width']) - 1
expected = [((x * 3) + 1) & mask for x in d['operations']]
assert expected == [10, 22, 37, 254]
assert len(d['stalls']) == len(set(d['stalls'])) and d['flush_cycle'] > max(d['stalls'])
print(f"PASS pipeline tokens={len(expected)} width={d['width']} ordering=preserved stall_cycles={len(d['stalls'])}")
