Strategy guides › Flapjack

How to sort Flapjack in par: count the gaps, then close them

Eigengames team Ā· 6 October 2026 Ā· 5 min read

ā–¶ Play FlapjackšŸŽÆ Try a stack that needs one patient flip

Seven pancakes, and the 7 is sitting in the middle of the stack. You know the move: slide the spatula under it, flip it to the top, flip the whole stack so it lands on the plate. Two flips, one pancake sorted. Do that six times and the stack is done.

It works every time. It also misses par most days. Here’s what the solver does instead, and how to do it in your head.

The textbook method, measured

ā€œBring the biggest unsorted pancake to the top, then flip it down into placeā€ is the classic way to sort pancakes, and it needs at most two flips per pancake. For seven pancakes the last two pancakes come almost free, so the worst case is 2n āˆ’ 3 = 11 flips. We ran it against the game’s own solver on 2,000 Normal stacks from our generator. It averaged 8.1 flips against an average par of 6.4, and it hit par on only 17% of them.

The reason is simple: the method only ever builds the stack from the plate up. It ignores every pair of pancakes that already sit next to each other in size somewhere higher up. Those pairs are free progress, and the method breaks them apart again.

Count the gaps: that’s your minimum

Look down the stack and check each touching pair. If the two sizes are neighbours (3 on 4, or 4 on 3), that pair is fine. If they’re not (6 on 2), call it a gap. Count the plate too: unless the 7 is at the bottom, there’s a gap between the bottom pancake and the plate.

1627534plategap?
The practice stack, top to bottom: 1, 6, 2, 7, 5, 3, 4. Only 3 on 4 are size neighbours, so it has six gaps, and no solution can take fewer than six flips.

Here’s why the count matters. A flip reverses the top of the stack, but inside that top section every pair stays neighbours with the same partner. The only pair that changes is the one where the spatula goes in. So one flip closes at most one gap. A sorted stack has none. That makes the gap count a hard floor on the number of flips, and mathematicians use it as the standard lower bound for this problem.

On our Normal stacks the floor is often the answer: par equals the gap count on 52% of them, one more than the gap count on 42%, and two more on 6%. So count the gaps before your first flip. If par is 6 and you count 6 gaps, every single flip has to close one. If par is one more than the count, you’re allowed exactly one flip that doesn’t.

The flip that closes a gap

Finding a gap-closing flip takes one glance, because it always involves the top pancake. Say the top pancake is the 4. Find the 3 or the 5 lower down and put the spatula directly above it. The flip brings the 4 down to rest on that neighbour and joins them. It closes a gap whenever the spot where you cut was itself a gap. If the top pancake is the 7, flipping the whole stack puts it on the plate, which closes the plate gap.

That gives you at most two candidate flips per move, one for each neighbour of the top pancake. Pick the one that leaves you another closing flip on the next move. Closing gaps isn’t just a hopeful heuristic: across every one of the 5,040 possible seven-pancake stacks, whenever a gap-closing flip existed, at least one of them was a correct first move of a shortest solution in 98% of cases. And when we followed shortest solutions through 2,000 Normal stacks, always taking a gap-closing flip whenever one was optimal, 91% of the flips closed a gap.

start6 gapsflip 25 gapsflip 34 gapsflip 53 gapsflip 33 gapsflip 22 gapsflip 71 gapflip 40 gaps
The par route for the practice stack, seven flips (the line shows where the spatula goes next). Every flip closes a gap except the fourth, marked in red: it closes nothing, but it lines up the 7, 6, 5 run for the next two flips.

When no flip closes a gap

Sometimes neither neighbour of the top pancake gives you a closing flip, or the only one leaves you stuck afterwards. That’s when you spend your ā€œfreeā€ flip. Make a flip that changes nothing in the count but puts a new pancake on top, one whose neighbour sits right under a gap. In the practice stack that’s the fourth flip. Both neighbours of the 5 on top were dead ends: the 6 and the 4 were each already joined to the pancake just above them, so cutting there only swaps one gap for another. After the free flip, 6 and 7 sit on the 5, and the next three flips each close a gap.

The shortcut to finding it is to look two flips ahead, not one. When we let a simple program play by ā€œpick the flip that leaves the fewest gaps after the next two flipsā€, it averaged 7.0 flips on Normal stacks and made par 54% of the time. That’s a big step up from the textbook method’s 8.1 and 17%.

Burnt pancakes and an open problem

Hard uses six burnt pancakes, and every flip turns over the pancakes it moves. The rule that trips people up: a pancake that is flipped down into place lands upside down. So before you send it down, its burnt side has to be facing up. The careful version of the textbook method takes up to three flips per pancake here (bring it up, turn it over if needed, flip it down). On our Hard stacks it averaged 11.2 flips against a par of 8.4. The gap count still works as a floor if you only count a pair as joined when the burnt sides also agree, but it’s looser: par runs two to five flips above it. So treat it as a warning, not a target.

The puzzle has a real history. It first appeared in 1975 as a problem in the American Mathematical Monthly. In 1979 Bill Gates and Christos Papadimitriou proved the first good bounds on the number of flips the worst stack of n pancakes can need, and introduced the burnt version. In 2009 a team at the University of Texas at Dallas improved the upper bound to 18n/11 flips. Nobody knows an exact formula; the known values are computer searches like ours. For seven pancakes the worst case is 8 flips, and only 35 of the 5,040 stacks need that many.

Practice

The practice stack is the one in the figures: six gaps, par 7, so you get exactly one flip that closes nothing. The textbook method needs 10 flips on it. Count the gaps, look at the top pancake, find its neighbours, and save your free flip for the moment both doors are shut.

One flip, one gap. Count them before you touch the spatula.

ā–¶ Play FlapjackšŸŽÆ Try a stack that needs one patient flip