from itertools import combinations from math import gcd from functools import reduce def run(load,check): data=load('C287_DATA.json');rows=[] for row in data['rows']: i=row['i'];coords=[row[x] for x in ['S','F','R']]+([row['Noah_required']] if row['complete'] else []) edges=[{'a':a,'b':b,'width_K':(coords[b]-coords[a])//529} for a,b in combinations(range(len(coords)),2)] check(f'all positive K edges i{i}',all((coords[e['b']]-coords[e['a']])%529==0 for e in edges)) paths=[] for mask in range(1<<(len(coords)-2)): ids=[0]+[k for k in range(1,len(coords)-1) if mask>>(k-1)&1]+[len(coords)-1] widths=[(coords[b]-coords[a])//529 for a,b in zip(ids,ids[1:])] paths.append({'nodes':ids,'widths_K':widths,'sum_K':sum(widths)}) check(f'all paths telescope i{i}',all(p['sum_K']==(19 if row['complete'] else 17) for p in paths)) check(f'no K or4K edge i{i}',all(e['width_K'] not in [1,4] for e in edges)) rows.append({'i':i,'coordinates':coords,'edges':edges,'increasing_paths':paths}) check('complete path decompositions',{tuple(p['widths_K']) for p in rows[2]['increasing_paths']}=={(19,),(2,17),(17,2),(2,15,2)}) check('gcd gives formal K only',reduce(gcd,[2,15,17,19])==1 and 17-8*2==1) check('distinct residue fibers',[(r['S']%529) for r in data['rows']]==list(range(6))) return {'rows':rows,'abstract_width_gcd_K':1,'formal_Bezout':'17K-8(2K)=K','source_path_warning':'Eight iterations of2K are not supplied by these four nodes. Inverse edges must share source endpoints; arbitrary width addition is not path composition.','annual_residue_fibers':list(range(6)),'full_field_annual_spacing':1}