Flipping blueberry pancakes

less than 1 minute read

Published:

Problem: You have a stack of 100 pancakes where the first pancake has one blueberry in it, the second has two blueberries in it, etc. If you randomize the order of the stack, then continuously flip the first x pancakes, where x is the number of blueberries in the top-most pancake (i.e. pick up the first x pancakes, reverse their order, and set them back down), can you prove that eventually the pancake with one blueberry will come to the top of the stack?

I heard this problem during my internship at Microsoft Research this summer and, with my lab-mate and fellow intern Fred Hohman, made an Idyll post that describes the problem, walks through our proof, and demos some Python code for further exploring the dynamics of pancake flipping! Check out our post and the accompanying code.