FiveThirtyEight

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

Riddler reader Eric Geiger was inspired by a paper presented at a conference called “Fun With Algorithms” and sent along this seemingly simple decorative problem:

Imagine a framed picture suspended by a cord that’s hanging on two nails. If the picture were hung “normally,” you’d expect the removal of one nail to leave the picture hanging from the other (albeit a bit askew). But how can you hang a picture on two nails so that if you remove either nail the picture will crash to the floor? This is a visual problem, so feel free to submit a link to an image, but a description will also do.

Submit your answer

Riddler Classic

What about three nails? What about four nails? What about on two red nails and two blue nails such that the picture falls if both red nails are removed and if both blue nails are removed but remains hanging if one of each color is removed?

Submit your answer

Solution to last week’s Riddler Express

Congratulations to 👏 Justin Ahmann 👏 of Bloomington, Indiana, winner of last week’s Riddler Express!

Last week, we examined your morning health regimen, in which you and your spouse each take two gummy vitamins. You share a single bottle of 60 vitamins, which come in two flavors. You each prefer a different flavor. Every day, you take the first four vitamins that fall out of the bottle and then divide them up according to your preferences. For example, if there are two of each flavor, you and your spouse get the vitamins you prefer, but if three of your preferred flavor come out, you get two of the ones you like and your spouse gets one of each kind. The question was, on average, what percentage of the vitamins you take are the flavor you prefer? (You could assume that the bottle starts out with a 50-50 split between flavors.)

About 82 percent of the vitamins you take will be the flavor you prefer.

Let’s start by considering a hypothetical bottomless bottle of vitamins containing an equal and infinite number of vitamins of each flavor. The vitamins — call them red and blue — could fall out of the bottle in the following ways, each of which is equally likely:

RRRR

RRRB, RRBR, RBRR, BRRR

RRBB, RBBR, RBRB, BRBR, BBRR, BRRB

BBBR, BBRB, BRBB, RBBB

BBBB

That leaves us with a total of 2×2×2×2 = 16 possibilities. (The 2s are because there are two options for each vitamin.)

Suppose you prefer red vitamins. Eleven of the possibilities contain at least two reds (guaranteeing you will be satisfied), four of the possibilities contain only one red (guaranteeing you’ll be only half-satisfied), and one of the possibilities contains zero reds (guaranteeing you will get none of the vitamins you prefer). So, on average, you will eat the vitamins you prefer (11/16) + (½)(4/16) + (0)(1/16) = 13/16, or 81.25 percent, of the time.

But remember that those aren’t the probabilities for the bottle we’re working with. They’re a very good approximation of our specific case of a bottle with 60 vitamins, but they’re not exactly right. With the real-world bottle, the probabilities aren’t independent because the vitamins we draw out today will affect the vitamins we draw out tomorrow.

In the 60-pill bottle case, let’s start by considering Day 1. The vitamins will come out according to something called the hypergeometric distribution, which sounds fancy but whose purpose is fairly simple: It describes the number of successes (the vitamins you like) in a random draw from a finite population (your bottle of vitamins) without replacement (you eat the vitamins once they come out). According to this distribution, the probability of drawing k vitamins you prefer in the first four you pull on Day 1 is given by

A calculation of that expression says that there is a 0.056 probability we’ll draw four vitamins we like, a 0.25 probability we’ll draw three, a 0.39 probability we’ll draw two, a 0.25 chance of one, and a 0.056 chance of zero. We can add all those up, weighted by the number of good vitamins we’ll eat: (0.056)(2) + (0.25)(2) + (0.39)(2) + (0.25)(1) + (0.056)(0) = 1.64 prefered vitamins. Finally, 1.64/2 is roughly 0.82, or about 82 percent.

We only need to consider the probabilities on this first day. What we draw on the first day will affect what we draw on subsequent days, but because of the initial symmetry of the flavors, things will balance out.

You could of course turn to a computer program to solve this problem, too, and many solvers did. Austin Jordan and Benjamin Phillabaum used Python code to simulate all this vitamin-taking, for example.

Solution to last week’s Riddler Classic

Congratulations to 👏 Jacob Kes 👏 of New York, winner of last week’s Riddler Classic!

This puzzle was focused on your landscaping: A grasshopper randomly landed somewhere on your lawn, which has an area of 1 square meter. As soon as it landed, it jumped 30 centimeters. What shape would your lawn have to be to maximize the chances that the grasshopper was still on the lawn after its 30-centimeter jump?

This difficult problem — one Riddler solver generously called it “thoroughly nontrivial” — was the subject of a recent physics paper by Olga Goulko and Adrian Kent, as well as a blog post by Sabine Hossenfelder. I won’t attempt to describe all the math that would go into an analytic description of the optimal lawn. It’s Friday, and, frankly, we don’t have the time. However, this problem turns out to be an excellent application for some well-known computer algorithms.

Zach Wissner-Gross approached the problem using a “greedy algorithm,” moving 1 square centimeter at a time. A greedy algorithm finds local optima at each stage, with the goal to be eventually finding a global optimum — in this case, the ideal lawn to retain a grasshopper. Zach was kind enough to share his MATLAB code. This is how the optimal lawn evolved as his algorithm did its work:

And our winner, Jacob, turned to the probabilistic technique called simulated annealing. He started with a 5-by-5 meter space divided up into 250,000 1-by-1 centimeter patches. He then randomly selected a lawn of 10,000 patches (1 square meter) in this space. At every step, he moved some number (gradually decreasing) of high-likelihood patches, where the grasshopper was often wont to land, into the lawn and an equal number of low-likelihood patches, where the grasshopper was not, out of the lawn. Eventually, this cools “into a ball with small bumps around the perimeter every 30 centimeters.” Jacob was also kind enough to share his code.

And, indeed, these two results are just what the physicists found! They concocted similar pictures for various lengths of grasshopper jumps, including our 30-centimeter case, which is shown in the fifth image on the top row:

They call this shape the “cogwheel.” For even longer grasshopper jumps, things get even weirder, and in certain cases, the best lawn shape was called the “three-bladed fan” or “stripes.” You can read more in the paper, in which Goulko and Kent also discuss potential applications of this grasshopper problem to catalytic reactions, morphogenesis and quantum information theory.

Want to submit a riddle?

Email me at oliver.roeder@fivethirtyeight.com.


Filed under