import numpy as np, itertools cp=(0,1,1,1,1,1); p=6 def rows_all(nu,K): """exact b_1..b_K for ALL assignments of u_0..u_{nu-1} (vectorised over assignments)""" U=np.array(list(itertools.product((0,1),repeat=nu)),dtype=np.uint8) # (2^nu, nu) T=nu*p; A=U.shape[0] d=np.array([cp[t%p] for t in range(T+K+2)],dtype=np.uint8) e=np.zeros((A,T),dtype=np.uint8) for t in range(T): ph=t%p; e[:,t]=U[:,t//p] if ph==0 else (1 if ph==5 else 0) cols={0:np.tile(d,(A,1)),1:e} for k in range(1,K): x,y=cols[k],cols[k-1]; cols[k+1]=x[:,1:]^(x[:,:-1]|y[:,:x.shape[1]-1]) return np.stack([cols[k][:,0] for k in range(1,K+1)],1) # (2^nu, K) nu=16; K=6*nu-6 B=rows_all(nu,K) print(f"exact rows for all 2^{nu} assignments, lanterns 1..{K}") for M in (30,40,50,60,70): alive=np.ones(B.shape[0],bool); blocks=[]; cur=[] for k in range(M,K): # constraint b_{k+1}=0 before=alive.sum(); alive&=(B[:,k]==0); cur.append(int(alive.sum()