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, 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 Adam Wagner, the Riddler comes better-late-than-never to an online craze:

The live smartphone game show HQ Trivia has taken the world by storm. In the game, you face a sequence of 12 multiple-choice trivia questions, each with three choices. If you answer all 12 correctly, you win a cash prize! Get one question wrong, however, and you are eliminated. If you didn’t know much trivia but did know strategy, how many phones would you need to guarantee that you’d win the cash on one of them?

Cool extra credit: The real-life game has an added wrinkle: extra lives, which you can earn by referring others to the game. You can use an extra life after you get a question wrong, and you continue just as if you had gotten that question right. However, you can use only one of these per game per phone. Assuming that all your phones have an extra life, how many phones do you need to guarantee a victory now?

Submit your answer

Riddler Classic

From Kate Seely, a gaming problem to which she would very much like to know the answer:

I have a matching game app for my 4-year-old daughter. There are 10 different pairs of cards, each pair depicting the same animal. That makes 20 cards total, all arrayed face down. The goal is to match all the pairs. When you flip two cards up, if they match, they stay up, decreasing the number of unmatched cards and rewarding you with the corresponding animal sound. If they don’t match, they both flip back down. (Essentially like Concentration.) However, my 1-year-old son also likes to play the game, exclusively for its animal sounds. He has no ability to match cards intentionally — it’s all random.

If he flips a pair of cards every second and it takes another second for them to either flip back over or to make the “matching” sound, how long should my daughter expect to have to wait before he finishes the game and it’s her turn again?

Submit your answer

Solution to last week’s Riddler Express

Congratulations to 👏 Jesus Petry 👏 of Porto Alegre, Brazil, winner of last week’s Riddler Express!

Last week found us in an improv class where five actors were performing. They all began a scene together, establishing a character for themselves. Three of those characters were heroes, and two were villains. Halfway through the scene, the actors all switched to playing one of the other characters, such that no one played the same character in both halves. What were the chances that at least one actor played a villain in both halves?

The chances were 5/11, or about 45.5 percent.

One way to solve the problem would be simply to list all the possible character changes and tally up the ones in which an actor played a villain twice. We could name the actors A, B, C, D and E and just start listing character assignments. But it’s very helpful, and efficient, to start with the concept of derangements. A derangement is a permutation in which none of the objects in a set (or an actor in an improv class) appears in its original place, just like we want here. For a class of three — ABC, for example — there are only two derangements: BCA and CAB.

For a class of five, our friends ABCDE, there are 44 derangements: BADEC, BAECD, BCAED and so on. Because there are four other roles an actor could take on, in one-fourth of these cases Villain 1 becomes Villain 2. Similarly, in one-fourth of these, Villain 2 becomes Villain 1. Two of those scenarios overlap, though: the ones where the two villains simply swap roles. That gives 11 + 11 – 2 (since we don’t want to overcount) out of the 44 in which at least one actor played a villain twice. That’s 20/44, or 5/11.

Solution to last week’s Riddler Classic

Congratulations to 👏 Mark Glickman 👏 of Baltimore, winner of last week’s Riddler Classic!

Last week, two garbled equations came across the desk at Riddler Intelligence HQ. One looked like this:

The other looked like this:

In the first, letters had been smudged and become illegible, represented above by dashes. We knew, however, that all 10 digits, 0 through 9, appeared in the equation. In the second, a mistake was made and one of the letters was incorrect. What letters correspond to what digits?

The true first equation is 6247663 + 6837633 = 13085296.

For starters, notice that only six different letters are shown: E, X, M, R, K and H. Because we know that all 10 digits are part of the equation, that means each of the four dashes must be a different digit. We can then rewrite the problem, substituting A, B, C and D for the dashes, as EXMREEK + EHKREKK = AKBHCXDE and go from there.

A slow and lengthy cascade of base-10 arithmetic logic then follows. For example, we can immediately deduce that the first dash in the top image above, our new “A,” must be 1, because the sum of two digits with carryover can’t be greater than 19. We also know, for example, that E must be even, because it is the sum of two of the same number (specifically, two Ks). We also know that E + E must be relatively large, because it creates carryover on the left side of the equation. With that, we’ve narrowed E down to either 6 or 8, which means that K must be 3 or 4.

We keep going in this fashion, inferring and eliminating possibilities for the letters and their corresponding digits. It’s all a bit like Sudoku, really. For the rest of the details, I’ll refer you to a selection of the excellent posts I received from Riddler Nation.

Kyle Pekosh and Matthew Bishop provided wonderful guides through their full solutions. Jaakko Järvinen even weighed in with a video. His voiceover begins with a fair assessment of the role this column plays in the world: “Now that I have nothing in particular to do with my life, I might as well solve a Riddler.”

The true second equation is 695513263 + 673596633 = 1369109896, and the K should have been a Y.

The logical ideas here are exactly the same, as are some of the “tricks.” For example, we know that E must be 1, because it is the carryover of the sum of two single digits. Also, because D + D = Y in the ones place and Y + Y = D in the 100-millions place, we know that D is 3 and Y is 6 — that is, 3 + 3 = 6 and 6 + 6 can equal “3” when there’s a carryover. And we chip away and we chip away.

Daniel Thompson used some cool tables to show the answer to Equation 2. Richard Holmes also provided excellent solutions.

And, as usual in Riddler Nation, you were more than welcome to turn to cold silicon for help. Keith Hudson shared his brute force Python code. Keith wrote: “The overall idea was to choose a wrong letter in the answer (starting with the ones digit of the first number) and then go through each permutation of possible answers.” It took his program 30 seconds to find the solution — and him a couple of hours to write it. Laurent Lessard noted that these sorts of puzzles are sometimes called cryptarithms, and he solved the problem computationally using integer programming. “The first problem took 0.005 seconds and the second problem took 0.3 seconds,” he wrote.

Given Laurent’s 0.005 seconds, next week we will be introducing Riddler Epic — a problem category solvable only by government lab supercomputers and certain extraterrestrial alien intelligences. Get your security-clearance application in now.

Want to submit a riddle?

Email me at oliver.roeder@fivethirtyeight.com.