"""Close calls of Reddit's The Button, by week: how often the countdown fell below 2 seconds, against chance. Usage: python3 button-close-calls.py thebutton_presses.csv Data: https://github.com/reddit/thebutton-data (thebutton_presses.csv, 1,008,315 rows). Standard library only. A close call is a press made with less than 2 seconds left: flair "0s" or "1s", the time left that Reddit recorded at the press. Chance: if a week's presses arrived at random at its average rate (λ presses a second), the countdown would fall below 2 seconds before a press, that is a gap over 58 seconds, with probability e^(−58λ); times the week's presses, that is the close calls chance would bring. We count from the recorded time left, not from the gaps between timestamps: hundreds of gaps in the log are 60 seconds or longer although the countdown only ran out once, so the timestamps are not precise enough to the second. Rows without a press ("non presser", or no flair) are left out: 1,001,291 presses. Weeks are counted from the first. (Used by unpressed.app/same-game since 27 Oct 2026, unpressed.app/why from 20 Oct; replaces the "protection factor" of research/insights-memo.md § 1.) """ import csv import math import statistics import sys from datetime import datetime WEEK = 7 * 86400 presses = [] with open(sys.argv[1], newline="") as f: for row in csv.DictReader(f): flair = row["flair"] if not flair or flair == "non presser": continue presses.append((datetime.fromisoformat(row["press time"]).timestamp(), int(flair.rstrip("s")))) presses.sort() start = presses[0][0] weeks = {} for t, left in presses: weeks.setdefault(int((t - start) // WEEK) + 1, []).append((t, left)) print(f"{len(presses):,} presses") print("week presses/day median left under 11 s close calls by chance share of chance") for w, ps in sorted(weeks.items()): n = len(ps) rate = n / (ps[-1][0] - ps[0][0]) # presses a second lefts = [left for _, left in ps] close = sum(left <= 1 for left in lefts) chance = n * math.exp(-58 * rate) share = f"{100 * close / chance:.1f} %" if chance >= 1 else "–" print( f"{w:>4} {rate * 86400:>12,.0f} {statistics.median(lefts):>10.0f} s {100 * sum(l < 11 for l in lefts) / n:>9.1f} %" f" {close:>12,} {chance:>10,.0f} {share:>16}" )