The second ticket was a tic-tac-toe game. Its design was straightforward: On the right were eight tic-tac-toe boards, dense with different numbers. On the left was a box headlined “Your Numbers,” covered with a scratchable latex coating. The goal was to scrape off the latex and compare the numbers under it to the digits on the boards. If three of “Your Numbers” appeared on a board in a straight line, you’d won. Srivastava matched up each of his numbers with the digits on the boards, and much to his surprise, the ticket had a tic-tac-toe.

As a trained statistician with degrees from MIT and Stanford University, Srivastava was intrigued by the technical problem posed by the lottery ticket. In fact, it reminded him a lot of his day job, which involves consulting for mining and oil companies.

Srivastava realized that the same logic could be applied to the lottery. The apparent randomness of the scratch ticket was just a facade, a mathematical lie. And this meant that the lottery system might actually be solvable, just like those mining samples. “At the time, I had no intention of cracking the tickets,” he says. He was just curious about the algorithm that produced the numbers. Walking back from the gas station with the chips and coffee he’d bought with his winnings, he turned the problem over in his mind. By the time he reached the office, he was confident that he knew how the software might work, how it could precisely control the number of winners while still appearing random. “It wasn’t that hard,” Srivastava says. “I do the same kind of math all day long.”