from itertools import product from collections import Counter def run(load,check): cover=load('C271_COVERAGE.json');check('eight boundary records each',all(r['total_source_indices']==8 for r in cover)) rows=[];counts=Counter();hits23=[];hitsK=[] for s,f,r,j,i,k in product(range(2),range(2),range(2),range(8),range(8),range(2,8)): S=-5890+j-460*s;F=-5290+i-460*f;R=3103+k-460*r a,b=F-S,R-F row={'s':s,'f':f,'r':r,'Shem_index':j,'Flood_index':i,'regular_index':k,'first':a,'second':b,'total':a+b} good23=a%23==b%23==0;goodK=a%529==b%529==0 row.update({'both23':good23,'bothK':goodK});rows.append(row) counts['both23' if good23 else 'not_both23']+=1;counts['bothK' if goodK else 'not_bothK']+=1 counts['firstK']+=a%529==0;counts['secondK']+=b%529==0;counts['totalK']+=(a+b)%529==0 if good23:hits23.append(row) if goodK:hitsK.append(row) check('complete domain3072',len(rows)==3072) check('23 criterion recovers selector relation',all((x['both23'])==(x['Flood_index']==x['Shem_index']-2 and x['regular_index']==x['Shem_index']) for x in rows)) check('48 rows at first23 filter',len(hits23)==48) check('K criterion recovers states',all(x['bothK']==(x['both23'] and (x['s'],x['f'],x['r'])==(1,0,1)) for x in rows)) check('six allK rows',len(hitsK)==6 and {x['Shem_index'] for x in hitsK}==set(range(2,8))) check('all surviving widths',[x['first'] for x in hitsK]==[1058]*6 and [x['second'] for x in hitsK]==[7935]*6) check('count crosschecks',[counts[x] for x in ['firstK','secondK','totalK']]==[72,96,192]) return {'domain_size':len(rows),'counts':dict(counts),'all_rows':rows,'all_K_hits':hitsK,'analytic_conditions':['a=600+i-j+460(s-f)','b=8393+k-i+460(f-r)','a,b divisible23 iff i=j-2 and k=j in the held ranges','additional factor23 selects s=1,f=0,r=1']}