#!/usr/bin/env python3 """job #1965 — @31 only, 2^26-position chunks, with a progress trace. Same object and convention as `job1965-comb31.py` (see that header). Prints progress lines to stdout (they are not part of the artifact log) and appends the single @31 record to the log file. """ import json import sys import time import numpy as np MIDS = [7, 11, 13, 17, 19, 23, 29, 31] CH = 1 << 26 def main(): log, progress_every = sys.argv[1], 200 W, N = 200560490130, 2 for p in MIDS: N *= p - 2 rho = N / W print(f"W={W} N={N} rho={rho!r} chunks={-(-W // CH)}", flush=True) t0 = time.time() amax, amin, count, nch = -1e18, 1e18, 0, 0 for base in range(0, W, CH): size = min(CH, W - base) a = np.ones(size, dtype=bool) for p in MIDS: a[(-base) % p::p] = False a[(p - 2 - base) % p::p] = False mask = np.zeros(size, dtype=bool) for c in (11, 17): mask[(-base + c) % 30::30] = True a &= mask f = np.flatnonzero(a) if f.size: vals = (count + np.arange(f.size)) - rho * (base + f) amax = max(amax, float(vals.max())) amin = min(amin, float(vals.min())) count += int(f.size) nch += 1 if nch % progress_every == 0: print(f"chunks {nch} bytes_scanned≈{nch * CH} elapsed {time.time() - t0:.1f}s " f"points {count}", flush=True) rec = {"level": 31, "W": W, "k": len(MIDS), "N": N, "N_scanned": count, "count_ok": count == N, "rho": rho, "maxA": amax, "minA": amin, "D_mine": amax - amin, "D_corrected": (amax + 1 - rho) - min(amin + rho, 0.0), "seconds": round(time.time() - t0, 2)} rec["slack_corrected"] = (2 * 3 ** len(MIDS)) / rec["D_corrected"] rec["slack_mine"] = (2 * 3 ** len(MIDS)) / rec["D_mine"] with open(log, "a", encoding="utf-8") as fh: fh.write(json.dumps(rec, sort_keys=True) + "\n") fh.flush() print(json.dumps(rec, sort_keys=True), flush=True) if __name__ == "__main__": main()