Atelier des rouesLab FR
Objects/Documentation

periode12.py

I provide this item to inspect or reproduce the check AT.P15.

Download ↓
"""Minimal number of successor states needed to reproduce an entire cyclic sieve word."""
from math import gcd,prod,isqrt
import json

def run():
    primes=(2,3,5,7,11);R=prod(primes)
    word=bytes(gcd(x,R)==1 for x in range(R))
    # A shift defines a period iff it preserves a full cycle.
    periods=[d for d in range(1,R+1) if word[d:]+word[:d]==word]
    assert periods==[R]
    # Different infinite tails can be separated by successively refining the current output.
    states=list(word);horizon=1
    while len(set(states))<R:
        names={};states=[names.setdefault((states[i],word[(i+horizon)%R]),len(names)) for i in range(R)]
        assert len(names)>1
        horizon+=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.