Why a Simple Bingo Number Picker Breaks by Round 70 and How to Fix It
A common approach to drawing non-repeating random numbers uses rejection sampling, which becomes increasingly inefficient as fewer numbers remain in the pool. By round 70 of a 75-number Bingo game, the loop may iterate up to 15 times per draw, with no guaranteed upper bound. A better solution builds a set of remaining numbers and makes exactly one random call per draw, capping worst-case complexity at O(75) regardless of game state. Injecting the random function as a parameter also makes the logic fully deterministic and unit-testable without mocking globals. Additional considerations like duplicate card detection, derived game state, and multi-window sync via BroadcastChannel further harden a deceptively simple feature.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in