#!/usr/bin/env python3 """Write the 60 labelled STS(27)s for seed 20261203, one design per line. Each line contains 117 decimal bit masks in the manuscript's block order. The set bit positions are the three point labels of a block. This module has no dependencies outside the Python standard library. """ from itertools import combinations, permutations, product from random import Random def base_lines(): def on_line(line): return all(sum(coordinate) % 3 == 0 for coordinate in zip(*(divmod(point, 3) for point in line))) return [line for line in combinations(range(9), 3) if on_line(line)] def latin_squares(): """Order Latin squares by first occurrence among relabelled addition tables.""" orders = list(permutations(range(3))) squares = [] for row_perm, col_perm, value_perm in product(orders, repeat=3): square = tuple(value_perm[(row_perm[x] + col_perm[y]) % 3] for x, y in product(range(3), repeat=2)) if square not in squares: squares.append(square) return squares def sample(): lines = base_lines() squares = latin_squares() assert len(lines) == len(squares) == 12 rng = Random(20261203) for _ in range(60): masks = [7 << (3 * fibre) for fibre in range(9)] for i, j, k in lines: square = rng.choice(squares) for x, y in product(range(3), repeat=2): z = square[3 * x + y] masks.append((1 << (3 * i + x)) | (1 << (3 * j + y)) | (1 << (3 * k + z))) yield masks if __name__ == "__main__": for blocks in sample(): print(*blocks)