# Pancake Sorting

This activity is inspired by a problem first introduced in 1975 by Harry Dweighter in the American Mathematical Monthly. The question is not only to sort the pancakes, but to determine `f(n)` the minimal amount of flips mandated to sort any stack of size `n`.

This problem is now famous because Bill Gates authored (with C. Papadimitriou) his only scientific publication in 1979 on this topic, providing a faster algorithm and proving that `17n/16 ≤ f(n) ≤ (5n+5)/3`. This was the only publication of Bill Gates before he invented Windows and became rich.

Then, David X. Cohen, the inventor of the Futurama comics with many mathematical references, introduced the variant with burnt pancakes and studied its complexity with Manuel Blum in 1993.

An article of 2012 (by L. Bulteau, G. Fertin and I. Rusu) proved that determining the minimal amount of flips to sort the stack is a NP-complete problem. Naturally, the stack sorting problem is not NP-complete since it can be solved in 2n-3 steps with the naive algorithm and (5n+5)/3 steps with the Gates algorithm. That's determining the minimal amount of steps that is NP.

Further information can be found on the wikipedia page, as usual.

This activity is also integrated to CSIRL (my repository of free unplugged activities to introduce computer science, available at http://www.loria.fr/~quinson/Mediation/SMN/), and it may be interesting to run the unplugged activities before implementing these algorithms in PLM.

### What can I do to improve this PLM universe?

As usual, there are several things that could be done in the code of this universe to improve it:

- A temporal view similar to the sorting universe could be helpful
- Other exercises, for example on the Roti sorting, with a pile of Roti that have to touch the grill on each face (see http://en.wikipedia.org/wiki/Pancake_sorting#The_identical_pancake_stack).