# t23.py - JOB #642: build the gap word of T_23 exactly (W = 23# = 223,092,870), # from the definition in return #159 section 0: T_x = slots mod x# with # gcd(r(r+2), x#) = 1, gap word cyclic, every gap a multiple of 6. # Writes t23-gaps.npy for the downstream checks. # stdout is the artifact: every line above is a function of the input. The wall time goes to # stderr (fix for solveathome job #648), so stdout reproduces byte for byte on any machine. import numpy as np, hashlib, sys, time PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23] W = 1 for p in PRIMES: W *= p t0 = time.time() cop = np.ones(W + 3, dtype=np.bool_) for p in PRIMES: cop[0::p] = False twin = cop[:W] & cop[2:W + 2] idx = np.flatnonzero(twin).astype(np.int64) D = len(idx) EXP = 1 * 3 * 5 * 9 * 11 * 15 * 17 * 21 # prod over 3 <= p <= 23 of (p-2) print("W = %d, D(T_23) = %d, prod(3<=p<=23)(p-2) = %d, %s" % (W, D, EXP, "EQUAL" if D == EXP else "MISMATCH")) gaps = np.diff(idx) wrap = int(idx[0] + W - idx[-1]) gapword = np.append(gaps, wrap) print("gap word length = %d; min %d max %d; all multiples of 6: %s; sum = W: %s" % (len(gapword), gapword.min(), gapword.max(), bool((gapword % 6 == 0).all()), int(gapword.sum()) == W)) np.save("t23-gaps.npy", gapword) np.save("t23-slots.npy", idx) print("sha256(gapword bytes) =", hashlib.sha256(gapword.tobytes()).hexdigest()) print("first slots:", idx[:6].tolist(), "last slots:", idx[-4:].tolist()) print("%.1f s" % (time.time() - t0), file=sys.stderr)