Atelier des rouesLab FR
Objects/Documentation

profondeur.py

Breadth-first search within a small factorial block. exit_depth finds the first other admissible address. Excluded ranks are allowed as intermediates.

Download ↓
"""Distance exacte de sortie dans un bloc (les intermédiaires sont libres)."""
from collections import deque
from functools import lru_cache
from math import factorial, gcd
import sources
from roues import rank, unrank


@lru_cache(maxsize=4096)
def layers(k, s):
    start = unrank(k, s)
    seen = {start}
    queue = deque([(start, 0)])
    by_distance = []
    while queue:
        word, d = queue.popleft()

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.