from pathlib import Path from itertools import product from collections import Counter import re def run(load,check): text=(Path(__file__).resolve().parent.parent/'sources/FILE_18.md').read_text() parsed=re.findall(r'\| (MT|LXX — native Cainan ON|SP) \| (\d+)→(\d+) \| (\d+)→(\d+) \| (\d+)→(\d+) \|',text) check('three canonical Flood rows',len(parsed)==3) targets=[] for name,*nums in parsed: trad='LXX' if name.startswith('LXX') else name;native=int(trad=='LXX') for pos,B in enumerate(map(int,nums)): g=3-pos//2;role='Flood start' if pos%2==0 else 'Flood close' for c,t,z in product(range(2),repeat=3): y=B+130*(c-native)+60*t-215*(1-z) targets.append({'tradition':trad,'gear':g,'role':role,'Cainan':c,'Terah60':t,'full430':z,'center':y,'base_native_Cainan':native,'base_center':B}) check('144 qualified target records',len(targets)==144) sources=[];hits=[];hist=Counter();tested=0 for s,f,j,i in product(range(2),range(2),range(8),range(8)): S=-5890+j-460*s;F=-5290+i-460*f;a=F-S row={'Shem_Cainan':s,'Flood_Cainan':f,'Shem_index':j,'Flood_index':i,'S':S,'F':F,'first':a};sources.append(row) for y in targets: b=y['center']-F;tested+=1;good=a%529==b%529==0 hist['bothK' if good else 'not_bothK']+=1 if good:hits.append(dict(row,target=y,second=b,total=a+b)) check('complete36864 domain',tested==36864) check('only six hits',len(hits)==6) check('only restoredMT full430',all((h['target']['tradition'],h['target']['Cainan'],h['target']['Terah60'],h['target']['full430'])==('MT',1,1,1) for h in hits)) check('only2K15K17K',all((h['first'],h['second'],h['total'])==(1058,7935,8993) for h in hits)) check('indices2through7',sorted(h['Shem_index'] for h in hits)==list(range(2,8))) return {'target_register':targets,'source_pairs':sources,'comparison_count':tested,'counts':dict(hist),'all_K_hits':hits,'regular_domain':'3 traditions x2 Cainan x2 Terah x2 sojourn x3 Gear x2 event boundaries','phase_policy':'Each target retains its inherited pair center+/-1/4; no phase is searched'}