#!/usr/bin/env python3 # -*- coding: utf-8 -*- """cover90scan.py — job #2731 control: for a FIXED residue tuple, how long is the longest covered run over a much larger range of placements x than the recorded window scan? Why this is a separate experiment from the search. The recorded lower bound a(25) >= 2027 for this route is the longest run found inside a SMALL offset range (the recorded window start is 227). The run structure of a fixed tuple V is a function of the placement x, and nothing in the record measures whether 2027 is a property of V or of the window that was scanned. A covered run of >= 2454 anywhere is exactly the assignment's witness, so the cheap question to ask first is: does this tuple already have one further out? Method: exact per-offset counts on [0, L), hole positions by flatnonzero, longest run = largest gap between consecutive holes (with the two boundary runs counted). Recomputed from scratch; nothing incremental. """ import argparse import hashlib import json import time import numpy as np import cover90 as C def longest_run(residues, L): cnt = C.coverage(residues, L) holes = np.flatnonzero(cnt == 0) if holes.size == 0: return {"run": L, "start": 0, "holes": 0} d = np.diff(holes) gaps = [int(holes[0])] # run before the first hole if d.size: gaps += [int(x) - 1 for x in d] # run between consecutive holes gaps += [int(L - 1 - holes[-1])] # run after the last hole i = int(np.argmax(gaps)) if i == 0: start = 0 elif i <= d.size: start = int(holes[i - 1]) + 1 else: start = int(holes[-1]) + 1 return {"run": int(max(gaps)), "start": start, "holes": int(holes.size)} def main(): ap = argparse.ArgumentParser() ap.add_argument("--residues", help="JSON list, or a cover90search output file") ap.add_argument("--L", type=int, default=4_000_000) ap.add_argument("--out", required=True) a = ap.parse_args() res = C.STATE_RESIDUES src = "served state (check-2043.out.json)" if a.residues: d = json.load(open(a.residues, encoding="utf-8")) if isinstance(d, dict): res = d.get("best_residues") or d["residues"] src = a.residues else: res = d src = a.residues t0 = time.time() r = longest_run(res, a.L) out = {"tool": "cover90scan/1", "at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), "source": src, "residues": res, "L": a.L, "residues_sha256": hashlib.sha256( json.dumps(res).encode()).hexdigest()[:16], "longest_run": r["run"], "longest_run_start": r["start"], "holes_in_range": r["holes"], "beats_published_2027": r["run"] > 2027, "meets_bar_2454": r["run"] >= 2454, "seconds": round(time.time() - t0, 2)} json.dump(out, open(a.out, "w", encoding="utf-8"), indent=1) print(json.dumps(out, indent=1)) return 0 if __name__ == "__main__": import sys sys.exit(main())