Welcome to The Riddler. Every week, I offer up problems related to the things we hold dear around here: math, logic and probability. There are two types: Riddler Express for those of you who want something bite-size and Riddler Classic for those of you in the slow-puzzle movement. Submit a correct answer for either,^{1} and you may get a shoutout in next week’s column. If you need a hint or have a favorite puzzle collecting dust in your attic, find me on Twitter.

## Riddler Express

From Ian Rhile, a riddle regarding a ring of rings:

Suppose you have N circles, all of which are joined so that their centers lie on a larger circle. For example, if N happened to equal 12, you’d have a figure like this:

What is the ratio of the diameter of the larger circle to the diameter of the smaller circles?

## Riddler Classic

From Ben Wiener, a puzzle inspired by a conference he attended in downtown Los Angeles:

You and I are meeting a friend at a restaurant in a city whose streets are laid out in a grid. All the city’s intersections have pedestrian signals that only let people walk in one direction at a time. The signals alternate, and every “walk” and “don’t walk” signal lasts exactly the same amount of time from start to finish. Any given intersection at some moment in time might look like this, for example:

We’re located at point A in the image below, and the restaurant (point B) is one block north and two blocks east. There’s a “walk” signal allowing us to go north and a “don’t walk” signal stopping us from going east, with a big red timer counting down to when it will change. The timer reads 1 second.

We’re visiting this city and don’t know anything about the other intersections — we can assume that their signals are at random points in their cycles, but we aren’t sure of the cycles’ length. (You can call it *T*.) We want to meet our friend as soon as possible. But we are only allowed to cross one street at each intersection, and we can never jaywalk.

Which direction should we go? And what happens from there?

## Solution to last week’s Riddler Express

Congratulations to 👏 Thomas McDaniel 👏 of Wheaton, Illinois, winner of last week’s Riddler Express!

Last week, you were playing a standard game of Texas Hold ’em. That’s the game in which you start with two cards, up to five community cards are dealt, and the object is to make the best five-card hand out of the seven cards available to you. In this particular game, you were interested in making the best possible hand once the board had been dealt — such a hand is called the “nuts.” Which two-card starting hand was the most likely to make the nuts?

That would be an ace and a 10 of the same suit, also called “**ace-10 suited**” or, in poker notation, ATs.

This answer is a bit surprising at first. ATs is certainly not the best starting hand in normal play — that is, it’s not the hand most likely to win against other hands. (AA takes that crown.) But it is the most likely to yield the best *possible* hand that can be made given the five community cards. The key is to build a strategy around the “nut flush” — the highest possible flush available using a given board of cards.

When first thinking about this question, there are a handful of possible answers to consider. The obvious ones include a pair of cards (AA, KK, TT, etc.) and some suited cards (AKs, ATs, JTs, etc.). The pairs are potentially attractive because they can make the nuts on a board that includes the same pair — in that situation, four of a kind is often the best hand. Suited cards, especially those that are close together in rank, are potentially attractive because on boards that don’t include a pair, they can make nut flushes or straights or even straight flushes.

Upon closer examination, suited-ace hands have an advantage over pairs. An ace and another card of the same suit make a nut flush on far more boards than a pair of aces makes the nut four of a kind, for example. Many suited-ace starting hands also have an advantage over suited hands that don’t include an ace — like JTs. That’s because the possibility of hitting an ace-high nut flush outweighs the nut straights and straight flushes that JTs might buy you.

But which suited-ace hand do we want to start with? AKs is an obvious guess. But ATs will hit all the nut flushes that AKs (or AQs or AJs) will. ATs also makes more straight flushes than AKs.^{2} And ATs guards against other hands in a way that AKs does not. For example, if the board includes the 6, 7, 8 and 9 of spades (with some useless fifth card), AK of spades would not be the nuts because JT of spades would beat it (flush vs. straight flush). But the JT of spades can’t exist in our ATs scenario — the 10 of spades would be in our hand. Further discussion about the intuition behind this solution broke out last week on the /r/poker subreddit.

Riddler Nation wasn’t the first group of solvers to tackle this question. In 2010, a user on the poker forums of Two Plus Two ran 10 million random trials for each hand. (This can also be done in a program such as Odds Oracle.) ATs wound up making the nuts about 4.3 percent of the time, AJs about 4.2 percent and AQs about 4.1 percent. AKs, a very popular answer to this Riddler, also made them about 4.1 percent. JTs made them about 3.4 percent, and AA only about 1.9 percent. (The worst hand for these purposes, 62 unsuited, made the nuts 0.1 percent of the time.)

That’s nuts!

## Solution to last week’s Riddler Classic

Congratulations to 👏 Aaron Berger 👏 of New Haven, Connecticut, winner of last week’s Riddler Classic!

Last week, we stayed at the gambling table to play some Shut the Box: a traditional pub game played with dice. The rules are as follows: The game’s box features nine tiles bearing the numbers 1 through 9. Those tiles rest on flippable levers, all of which begin the game “open.” To start the game, you roll two standard dice. You can then “shut” any combination of number tiles that add up to the total of your dice. Once a number is shut, it stays shut. After you’ve shut your chosen numbers, you roll again and repeat the process. (During the game, once the 7, 8 and 9 are shut, you may choose whether to roll one die or two dice. If any of those numbers are still open, you must roll two dice.) You win if you close all of the numbers before you run out of legal moves. If you play perfectly, what are your chances of successfully “shutting the box”?

Your chances are about **9.8 percent**.

This puzzle is an exercise in dynamic programming — that is, breaking a problem down into a bunch of smaller problems, solving those, and using those solutions to build up a solution to the big original problem. In this case, the smaller problems are the various states in which you might find the levers during the course of the game. There are nine levers, each of which can be either open or shut; therefore there are possible states.

Solver Hector Pefo wrote up his excellent solution, including his Python code. His dynamic programming logic goes like this: Label a lever “1” if it’s shut and “0” if it’s open, and let “P()” be the probability of winning the game in a given state. The number we eventually want to find — the solution to this Riddler — is P(000000000): the probability you win when all the levers are open at the beginning of the game.

One of the states is easy to calculate: P(111111111) = 1, because in that state the levers are all closed and you’ve won for sure! Other states are a bit trickier. Let’s say that we want to calculate P(100111111), which is the probability that we win when the “2” and “3” levers are open and everything else is closed. In this situation, according to the rules of the game, we can choose to roll either one die or two dice.

First, suppose that we choose to roll one die. In that case, we win instantly if we roll a 5 (we can split that 5 between the open 2 and 3). And we can keep playing if we roll a 2 — we then find ourselves at P(110111111) — or a 3 — we find ourselves at P(101111111). So the chances that we win if we roll one die in this case are:

P(100111111 | roll 1 die) = (1/6) + (1/6) P(110111111) + (1/6) P(101111111)

Second, suppose that we choose to roll two dice. We win instantly if we roll a 2 and a 3, and we can keep playing if we roll two 1s or a 1 and a 2.

P(100111111 | roll 2 dice) = (2/36) + (1/36) P(110111111) + (2/36) P(101111111)

If we’re playing the game perfectly, as the puzzle called for, we’ll choose the rolling strategy that gives the higher probability of winning, which becomes our sub-solution, P(100111111). (That solution is to roll one die, in this subproblem.) We repeat a similar process for the rest of the subproblems.

There are a lot of these to go, so we’ll let a computer work through the remaining 510 states. Jimmy Waters also shared his code, including a large table of the win probability for each possible state. Eventually, with the help of our silicon friend, we find that P(000000000) ≈ 0.0976, or about 9.8 percent.

Happy rolling, Riddlers!

## Want to submit a riddle?

Email me at oliver.roeder@fivethirtyeight.com.