Took another one week hiatus from The Riddler, but am back to this one’s!

The Riddler is a weekly puzzle series from Oliver Roeder at FiveThirtyEight that usually involves some combination of math, logic and probability.

This weeks FiveThirtyEight Riddler, Can You Solve the Puzzle of the Picky Eater is:

Every morning, before heading to work, you make a sandwich for lunch using perfectly square bread. But you

hatethe crust. You hate the crust so much that you’ll only eat the portion of the sandwich that is closer to its center than to its edges so that you don’t run the risk of accidentally biting down on that charred, stiff perimeter.How much of the sandwich will you eat?

Extra credit: What if the bread were another shape — triangular, hexagonal, octagonal, etc.? What’s the most efficient bread shape for a crust-hater like you?

So let’s start with a 2 x 2 square, as picture below

To simplify things we’re only going to deal with the first quadrant, specifically half of the first quadrant (see shaded portion. To find the area closer of the shaded triangle that’s closer to the center than the edge, we need to find a function f(x) that represents the all the points that are equidistant from the edge to the center. The distance of that equation from the center is defined by: **sqrt(x ^{2} + f(x)^{2})**

The distance from that equation to the edge in the shaded portion is defined by: **1‑x**. Set the two equal to each other, and solving for f(x) produces: **f(x) = sqrt(1–2x)**. So our plot now looks like:

The shaded area can be split up into two distinct areas. The area under g(x) from 0 to the intersection of g(x)/f(x) (which we’ll call c). And the area under f(x) from c to 0.5.

g(x) is defined by that angle theta, which in the case of a square shape evaluates to: **g(x) = x**. We set g(x) = f(x), and solving for x will provide c. So we need to solve x in:r **cotangent(θ)*x = sqrt(1–2x)**. That yields **x = c = 2 ^{1/2} — 1**.

To solve for the area underneath our curve we evaluate: **[Integral g(x) from 0 to c] + [ [Integral f(x) from c to 0.5]**. Since g(x) is a triangle with a base and height of c and g© respectively , the **[Integral g(x) from 0 to c] **term is **0.5*c ^{2}*cotangent(θ)**. We’ve simplified our equation now to:

**[0.5*c**Using

^{2}*cotangent(θ)] + [ [Integral f(x) from c to 0,5].**c = 2**we solve and get the area of the shaded region to be:

^{1/2}— 1**0.1094**. The base and height of the triangle in the first quadrant (shaded region in the 2nd picture) is 1 and g(1) respectively. So the area of that triangle computes to

**1*g(1)*0.5 = 0.5**. So the proportion of the sandwich eaten is:

**0.1094/0.5 = .2190.**

The answer to this week’s Riddler is **“You will eat 21.9% of the sandwich”.**

**Extra Credit**

So now for the extra credit, we look at other shapes. Let’s take for example a hexagon, as shown in the graph below.

Just as before we’re only concerned with the first quadrant, specifically the shaded triangle in the first quadrant.

You’ll see that a lot of the math we did still applies. f(x) remains sqrt(1–2x). The only variable that’s changed is theta. Changing theta changes the value of g(x), which in turn changes the value of area of the shaded triangle and value of c, but since those are all dependent on theta, the only term we need to be concerned with is theta. Theta in the case of the square was 45o, and in the case of the hexagon is 60o. The general equation for theta, in a regular polygon with n sides can be defined by **θ = [(n‑2)*( π/2)]/[n*2]**. So in the general case of a polygon with n sides our steps are:

- Find Theta via
**θ = [(n‑2)*(****π**/2)]/[n*2] - g(x) is now defined by g(x) =
**cotangent(****θ)*x** - f(x) remains
**f(x) = (1–2x)**as per the equation solved earlier^{1/2} - Solve f(x) = g(x) for the intersection point of the two curves which we’ll define as
**c** - Integrate g(x) from 0 to c, which can be simplified to
**[0.5*c**^{2}*cotangent(θ)] - Integrate f(x) from c to 0.5
- Add up the results of steps 5 & 6 to find the area of the sandwich eaten for that sub-section in 1st quadrant
- Calculate the area of the entire sub-section in the 1st quadrant, defined by
**1*g(1)*0.5** - Divide the result of Step 7 by Step 8 to find the proportion of sandwich eaten by the picky eater.

Rather than doing this all by hand, I wrote up a script in R for n in 3:50, which can be found here on my Github. That generated the following results:

We can see as the number of edges (n) gets larger, the proportion of sandwich eaten approaches 0.25. A polygon with infinite edges is a circle.

For a circle with radius r, the area that is equidistant to the center as it is to the edge is defined by the concentric circle with radius r/2. In that case the proportion eaten is:** [(r/2) ^{2}*π]/[r^{2}*π] **which simplifies to

**In the context of the graph this makes sense.**

**0.25**.**We conclude that the most efficient shape is a circle, with 25% of the sandwich being eaten. **