## Spaghetti Puzzle #1

About a month ago, math educator Marilyn Burns tweeted this puzzle:

Spoiler Alert: Stop here if you want to solve the puzzle yourself!  Answers (some correct and some not) will be given below.

This innocent-seeming puzzle stirred several math teachers to exchange ideas, diagrams and animations.  Some of them changed their minds about it as they worked through the problem.  For example, Simon Gregg first thought that the answer is 1/4:

Upon further reflection, he changed his answer to 1/3:

There were some who used calculus to find a probability of 0.386.  Gregg came to suspect they were right:

My Attempts

I approached the problem in a few ways myself.  I thought about the sample space as sketched by Kaleb Allinson:

Assuming the spaghetti stick is one unit long, the horizontal axis represents the length of the shorter piece after the first break.  Let’s call this $A$.  It must range between 0 and 1/2.  The longer piece is then itself broken into a left piece with length $B$ and a right piece with length $C$.  I interpret the vertical axis in Allinson’s chart as the length $B$.  It could range between just above zero to nearly one if $A$ is very small, and it could range between between zero and around 1/2 if $A$ itself is close to 1/2.  The length $C$ of the third side is not displayed in this diagram, but we can find it for any point $(A,B)$ by using $C = 1 - A - B$.

The sample space of possible $(A,B)$ points combines the three right triangles in Allinson’s diagram.  The shaded area in the middle represents the combinations of $A$ and $B$ that can lead to a spaghetti triangle.  These combinations work because of the triangle inequalities, which require that no side be longer than the sum of the other two sides.  Otherwise, the two shorter sides might just dangle pathetically off the long side like the arms of a T-Rex.

Allinson saw that one-third of the sample space corresponded to valid triangles, and so concluded that the probability of forming a triangle is 1/3.  However, all parts of the diagram are not equally likely.  All permitted values of $A$ are equally likely, but the distribution of $B$ depends on $A$.  When $A$ is very small, there is about a 50% chance that $B$ is less than 1/2.  In contrast, when $A$ is near 1/2, there is almost a 100% change that $B$ is less than 1/2.  The probability density in the diagram is not uniform; it increases from left to right.

In my mind, I pictured the probability density as a slanted roof above the diagram (in a third dimension).  By some mental calculation I concluded that the probability of landing in the shaded area (what we might call the “triangle of triangles”) was 1/2.

To check my result, I made a spreadsheet to simulate many random spaghetti snaps.  For each simulation, I sampled values for two random variables $X$ and $Y$, each uniformly distributed from 0 to 1.  I used $X$ to set $A$, the length of the shorter piece after the first break.  We can let $A$ equal the lesser of $X$ and $1-X$.  We then find the next piece with $B=Y\times (1-A)$.  As mentioned above, the third piece $C=1-A-B$.   I set up the model to run 10,000 simulations and flag which ones could form triangles.

This is the result of one run with the $A$ and $b$ values plotted for each simulation.  The blue dots indicate valid triangles.  It looks like one-third of the points are good for triangles.  However,  the points are more crowded on the right than the left, and there are 3,823 blue dots out of 10,000 total.  The blue triangle is denser than the orange areas and gets more than its share of the simulations.

Here is the same run plotted against the random variables $X$ and $Y$.  The blue dots take up about 38% of the area of this evenly distributed chart.

I ran the spreadsheet several times and each time about 38% or 39% of the simulations allowed triangles.  I had to doubt my answer of 1/2.  I realized that the probability surface was not simply flat incline but something with a curve to it.

I communicated by Twitter and email with Mike Andrejkovics, a math teacher and math rapper(!) .  He thought at first that the answer was 1/4 and he created a cool video to make his case.  Mike then realized that his solution applied to a slightly different problem (see Variations below).

Like some of the other math teachers on Twitter, Mike used calculus to find the answer of .386 for the Marilyn Burns version of the problem.  I decided to work through the calculus for myself.  Mike had gotten me thinking some more about the probability density.  None of the calculus solutions I had seen had provided an explicit formula for the probability density, but I thought that such a formula would clarify the problem for me.

Let $f(x,y)$ be our probability density function (“pdf”) over the sample space in Kaleb Allinson’s diagram.  This space ranges from 0 to 1/2 for the $x$ coordinate and from 0 to $1-x$ for the $y$ coordinate.  We use $x$ to represent the length of the shorter piece after the first break.  After the longer piece is broken into two pieces, the new piece on the left has length $y$.  The total probability over this space should equal one.  In calculus notation, this means

$\iint_{S}f(x,y)dydx=1$  or

$\int_{0}^{1/2}\int_{0}^{1-x}f(x,y)dydx=1$.

The first statement integrates $f$ over the sample space $S$.  The second statement is equivalent.  Working from the inside out, we begin by integrating $f$ as $y$ ranges from 0 to $1-x$.  This integral is basically just a function of $x$, so we can write $g(x)=\int_{0}^{1-x}f(x,y)dy$.  Now our double integral becomes the single integral

$\int_{0}^{1/2}g(x)dx=1$.

We want $g(x)$ to be constant, because we assume that  $x$ is uniformly distributed from 0 to 1/2.  The probability density in the sample space for each value of $x$ should be the same.  Now if $g(x)$ is constant, then it must equal 2 so that $\int_{0}^{1/2}g(x)=1$.  Now we work back to the function $f$.   We need

$\int_{0}^{1-x}f(x,y)dy=g(x)=2$,

which works with the pdf $f(x,y)=\dfrac{2}{1-x}$.  Note that $f$ is  a function of $x$ but not of $y$.  It grows along a curve from left to right.

Let’s look at this probability density function over the sample space.  The volume enclosed by the figure is exactly one cubic unit, as required.

I like this shape.  Every side could be made from a flat or rolled sheet of paper.  Maybe architects should study probability density functions for inspiration!

Now let’s complete the solution to the spaghetti problem.  We want to know the probability of landing in the shaded “triangle of triangles.”  Call this region $T$.  Then the probability of making a triangle is

$\iint_{T}f(x,y)dydx$

$=\int_{0}^{1/2}\int_{1/2-x}^{1/2}f(x,y)dydx$

$=\int_{0}^{1/2}\int_{1/2-x}^{1/2}\dfrac{2}{1-x}dydx$

$=\int_{0}^{1/2}\dfrac{2x}{1-x}dx$

$=2ln(2)-1\approx 0.386$

where $ln$ represents the natural logarithm.  I hope you don’t mind that I skipped over some of the integration steps at the end.

Let’s see what the solution looks like.  Here is the probability density with the region for valid triangles colored in red.  The volume of the red portion is 0.386.

Variations

The first version of the puzzle that Mike Andrejkovics solved appears as the “Walking Stick Puzzle” (#120) in The Puzzle Universe by Ivan Moscovich.  This book was a great Christmas present from my wife.  In the Walking Stick problem, the two breaks are made independently.  It is not required that the second break occur along the longer piece after the first break.

I told my daughter (with whom I blog at Zeno’s Meatball) about the spaghetti puzzle.  She interpreted the problem in physical terms.  How do spaghetti strands really break?  Aren’t they more likely to break near the middle than near the ends?  Perhaps we grownups have been too simplistic with our uniform distributions.

Stayed tuned for a new variation on the puzzle that I will present in an upcoming post.  I hope you enjoy it.

This entry was posted in Fun, Puzzles and tagged , , , , . Bookmark the permalink.

### 6 Responses to Spaghetti Puzzle #1

1. This is a terrific post. I especially appreciate the beautiful 3D plots of the sample space with the probability density. I’ve really enjoyed corresponding with you about this problem. It’s been great to uncover some new understandings of a classic version which I thought I had completely solved years ago!

Like

• Win Smith says:

Mike, thank you very much! I’ve also enjoyed our correspondence.

Like

2. Joseph Nebus says:

That’s a great post, and a great question. I’m delighted.

Like

• Win Smith says:

Thank you! It also looks like you have a very interesting blog. I look forward to exploring it.

Like

This site uses Akismet to reduce spam. Learn how your comment data is processed.