#!/usr/bin/env python3 """After the P>=210 cells are provably d<=1, the only deficit-capable territory is P=30 with small p (p <= A ~ 7..15). Price the P=30 rows of the route's original Mp<=3e8 space with p in {7,11,13} (the only p that can satisfy p <= A there).""" import itertools from math import prod PR=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] P=30; CAP=300_000_000 pc=[q for q in PR if q not in (2,3,5)] print("P=30, p<=A target (p in {7,11,13}):") print(f"{'|R|':>4s} {'R-sets':>7s} {'rows p in {7,11,13}':>20s} {'sum(Mp)':>11s} {'all rows Mp<=3e8':>17s}") tot=0; tots=0 for k in (3,4,5): nR=0; n=0; s=0; nall=0 for R in itertools.combinations(pc,k): M=P*prod(R) if M>CAP: continue nR+=1 for p in (7,11,13): if p in R: continue Mp=M*p if Mp<=CAP: n+=1; s+=Mp for p in pc: if p in R: continue if M*p<=CAP: nall+=1 tot+=n; tots+=s print(f"{k:4d} {nR:7d} {n:20d} {s:11.3e} {nall:17d}") print(f"{'tot':>4s} {'':7s} {tot:20d} {tots:11.3e}") print() print("Reference: the served census already contains the P=30 rows with Mp<=2.5e7 plus the 12 |R|=5 rows.") # how many of the p in {7,11,13} rows are already served (Mp<=2.5e7)? served=0 for k in (3,4,5): for R in itertools.combinations(pc,k): M=P*prod(R) for p in (7,11,13): if p in R: continue if 0