Imagine you have a circular cake, that is frosted on the top. You cut a d degree slice out of it, and then put it back, but rotated so that it is upside down. Now, d degrees of the cake have frosting on the bottom, while 360 minus d degrees have frosting on the top. Rotate the cake d degrees, take the next slice, and put it upside down. Now, assuming the d is less than 180, 2d degrees of the cake will have frosting on the bottom.

If d is 60 degrees, then after you repeat this procedure, flipping a single slice and rotating 6 times, all the frosting will be on the bottom. If you repeat the procedure 12 times, all of the frosting will be back on the top of the cake.

For what values of d does the cake eventually get back to having all the frosting on the top?

The solution will eventually be posted in the comments, but if you solve it before then, show off and post your own solution.

Here is a hint: the answer is not that the cake returns to all frosting on top if and only if d is rational.

Dammit, ignore by solution then. Although I don’t see my error yet.

I’m a bit suspicious, because your logic puzzles are usually hard, but this one seems easy.

Note that the operation “slice, flip, rotate” is bijective on the states of the cake. So when we repeat it we are either in a loop or an infinite chain. If d is rational then there are a finite number of states the cake can be in, so we must be in a loop. If d is irrational then each cut can never be in the same place as a previous one (so the to bits immediately to either side are the same way up) and so we cannot return to the starting state (since after the flip exactly one of these bits will be the wrong way up).

I am really happy that I got that reputation!

Only if d is a factor of 360. D is in degrees Im assuming.

Thank you for your guess. That is not correct.

Man, I also thought it was “iff d/360 is rational, or alternatively iff d is rational”. For every other number, is the number of steps before it’s back to normal 2 * LCM(d, 360) / d? The potential problem here is the seemingly innocuous generalization of LCM to rational inputs, which seems reasonable enough…

LCM(a / b, 360) = LCM(a, 360 * b) / b, right?

I don’t know what you mean by “for every other number.” The formula you gave does not give the correct number of steps for all rational inputs.

d=n*4*pi, where n=0, 1, 2…

Is that in radians or degrees? Either way, it is not the correct answer, because it does not include 60 degrees, which I showed is frosting up after 12 steps.

There is an obvious upper bound on d. The intersection of the rationals and (0, 360] should all be solutions.

I suppose I should have used [0, 360]

I am sorry, but this is not correct.

The problem with my above solution is that when we turn a piece over the cuts in it change places. So it’s possible that a new cut might land on them even if d is irrational.

My proof that rational numbers succeed still works. So if the answer isn’t “only the rational numbers” then I guess that it’s “all the numbers” since heuristically there’s no way to distinguish between irrationals using just addition and subtraction.

That’s not a proof though. I don’t see any way of proving that even any particular irrational number will work.

Irrational d will never have cuts that line up. A proof is trivial.

The rotations of the cake never line up, but the places where the cake is cut can line up.

I’ve put a more detailed sketch of the argument on the reddit thread by the same name as this page.

Your guess is correct!

Suppose that after c repetitions we have cd degrees of rotation with d irrational. Then to have the cuts line up again, cd + 360k for k an integer must be a rotation of the cake that will occur. This implies c + 360k/d cuts. If d is irrational, this is not an integer number of cuts.

When you flip a slice the “cuts” can move around.

Do you have a proof that irrationals will work? Without anything concrete it is only conjecture.

I just posted the proof.

As promised, here is the solution.

The frosting will eventually be all on the top of the cake for all angles! The key insight that you may have missed is that when you flip a slice, it not only moves frosting back and forth between the top and bottom of the slice, but also flips the slice from left to right!

Consider a d degree cut. Let d divide into 360 n times with remainder a. Let b=d-a. If a=0, then d divides 360, and the cake will return to normal after 2n flips. Otherwise, we will partition the cake into 2n+1 parts: n+1 “A wedges” of angle a degrees and n “B wedges” of angle b degrees. We will alternate between A and B wedges all the way around the circle. There will have to be two adjacent A wedges somewhere, and we will put the boundary between two adjacent A wedges at the cut at the beginning of the first slice of cake we will cut.

When we make the first cut, we swap the first A wedge and the first B wedge, and rotate so that those two edges are moved to the end of the circle. Now the cake is still divided into alternating A wedges and B wedges, with the two adjacent A edges at the start of the next cut!

We can look at the 4n+2 sides of wedges of the cake, and notice that every cut, flip, rotate move is a permutation on these 4n+2 sides of wedges. They will therefore all return to the original permutation after a finite number of steps. At which time, the cake will not only have all the frosting on the top, but be exactly the same as it started!

Suppose your layout is BABABABABAA, then we will have ABABABABABA after flipping the first 5 pieces, and we wil be in a place to flip the AA piece, eating into our B piece or not entirely cutting into our AA piece. Suppose your layout is ABABABABABA, then you will arrive at BABABABABAA and you will be in the position upon the next pass.

I haven’t thought that last post through entirely for ABABABABABA.

How do you reconcile this with the idea that you will never end up at the same location for rotation with d irrational?

All of the cuts you make get moved around every time you make a flip. They do not just move when you rotate. The rotations are irrational but the net movement from flips and rotations is periodic.

This never happens. It starts in that ABABABABABA configuration. When you flip the first slice, you get BAABABABABA, and when you rotate, you are back to ABABABABABA. You do not have to worry about things other than alternating A and B, because the move preserves the configuration.

Hey BWOC,

I shared this puzzle on a forum: http://brainden.com/forum/index.php/topic/17187-upside-down-cake/. It’s engaging a lot of members, and so far they’re all stumped. ðŸ™‚

Thanks again such amazing puzzles!

Thanks. This puzzle was not mine. I think I originally heard it on MathFactor, but I do not know where they got it. I mostly just collect obnoxiously hard puzzles, often modifying them slightly to make them harder. Poker interrupted, find the apples, and prime sided dice are the only ones that are originally mine. I especially enjoyed sharing this one with my friends, because when I gave them the hint that the answer is not “rationals,” everyone broke into two camps who thought it was a superset vs. subset of rationals and started arguing, repeating the same “proofs” back at each other.