Binary Search Is Efficient, But Never Guess Her Age With It
Why is this CS Fundamentals meme funny?
Level 1: The Worst First Guess
Someone says, "Guess my age!" and instead of guessing nicely, a guy treats it like the higher-or-lower number game: he starts right in the middle of all possible ages and confidently announces "Fifty!" — to someone who is clearly not fifty. Seeing her face, he "corrects" with "Twenty-five!", which only proves the first guess wasn't a slip. It's funny because his method really is the smartest way to win a number-guessing game — and the absolute fastest way to lose a friend. Some questions aren't puzzles to be solved; they're moments to be kind, and he brought a calculator to a compliment.
Level 2: How Binary Search Actually Works
Binary search is one of the first algorithms every programmer learns: to find a value in a sorted range, guess the middle; if your guess is too high, discard the upper half, if too low, discard the lower half; repeat. Each step halves the search space, so finding a number between 0 and 100 takes at most about 7 guesses — that's the O(log n) efficiency the tweet salutes (versus linear search, checking 1, 2, 3... one by one). It's the "think of a number, I'll ask is-it-higher-or-lower" game, played optimally.
The tweet's setup is faithful: midpoint of 0–100 is 50; told "lower," the next midpoint is 25. The algorithm needs three things the real world refuses to provide here: a cooperative oracle that honestly answers higher/lower, equal cost for every guess, and a search target that doesn't storm off after your first probe. It's a perfect early lesson in preconditions — an algorithm is only correct relative to its assumptions, and verifying those assumptions before deploying is the actual skill. The same energy ships an O(1) cache that's wrong, or a perfectly normalized schema nobody can query.
Level 3: Optimal in Comparisons, Catastrophic in Consequences
The screenshot is a dark-mode X post from the account Wise (@trikcode, verified, 516K views and 22.9K likes attesting that the bit landed):
Dear programmers,
While binary search is very efficient, if a girl asks you to guess her age, don't say 50 and then 25.
The joke is rigorous, which is why it works. Binary search over an assumed range of 0–100 probes the midpoint: (0 + 100) / 2 = 50. She reacts badly — interpreted as "too high" — so the algorithm recurses on the lower half: (0 + 50) / 2 = 25. Two comparisons, search space cut to a quarter, textbook $O(\log n)$ performance. Also: date over. The comic engine is a developer executing a provably optimal procedure inside a domain where the cost function was never the number of guesses. Binary search minimizes comparisons under the assumption that every probe costs the same. Human conversation violates that assumption spectacularly — the error isn't symmetric (guessing 50 at someone who's 28 is a social felony; guessing 22 is flattery), and each probe changes the system being searched, since after "50" there is no cooperative oracle left to answer your next comparison.
Formally, this is a mis-specified objective: the dev optimized worst-case query count when the real-world loss function is maximum single-probe overshoot. The socially correct algorithm is a biased linear scan starting well below any plausible value — deliberately $O(n)$, embracing algorithmic inefficiency because every wrong guess is a compliment. That inversion is the meme's quiet thesis, and it generalizes to a pattern seniors recognize in code review: greedy optimization of the measurable metric (latency, comparisons, sprint velocity) while the unmeasured constraint (trust, UX, the customer's feelings) silently dominates total cost. The "Dear programmers" open-letter framing seals it — the community's long-running self-roast about applying CS-fundamentals brain to situations that required reading the room, where the room is not a sorted array.
Description
A dark-mode Twitter/X screenshot from Wise (verified, @trikcode, with a lightning bolt badge and Subscribe button). The tweet reads: 'Dear programmers, While binary search is very efficient, if a girl asks you to guess her age, don't say 50 and then 25.' Posted 13:46, 09 Jan 26, with 516K views, 747 reposts, 64 quotes, 22.9K likes, 865 bookmarks. The joke maps the classic O(log n) bisection algorithm onto a social situation where the worst-case first probe (the midpoint of a 0-100 range) is catastrophically offensive - a clean collision of algorithmic optimality and social optimality
Comments
11Comment deleted
Linear search from 18 upward is O(n), but it's the only age-guessing algorithm where every comparison is a compliment
so if the usual life expectancy in Europe and the US in women is 80-ish, isn't it a trisection? should we start with 40 and then 20? Comment deleted
And since one is usually able to tell if a woman is 60+, we could start with 30 (and then 18 instead of 15) Comment deleted
guess 32.00000000004 Comment deleted
All the real ones start with 0 (When doing binary search) Comment deleted
FBI, open up Comment deleted
starting with 50 is too optimistic anyway Comment deleted
Why would a sane person ever start binary search with a non-power-of-2 initial guess?! 🤓 Comment deleted
truth nuke Comment deleted
Ofc not. Go the other way around. Comment deleted
Use ternary search instead. It's less efficient though Comment deleted