# Pancake Sorting

The pancake sorting problem is a simple puzzle where you have a set of pancakes, each of differing size. The chef cooking the pancake is a bit psychorigid: he hates when the pancakes are not correctly sorted on the plate. He loves when they are correctly ordered, with the small ones over the larger ones. As every pancake maker, he masters the pancake flipping with his spatula. He can flip the pancake on top of the stack, or even several pancakes at once. The thing is that he has only one plate and the table is too dirty to place pancakes on it, even temporary. The only allowed operation is to flip some pancakes that are on top of the stack.

Your work is to help this poor guy sorting his stack by flipping the pancakes. Each pancake is defined by its radius and rank within the stack, with the top-most pancake is at rank 0, and the one below at rank 1.

Note that you can play physically with pieces of paper or wood at first to get the grasp on this problem. This is even one of the activities that I use in my CS-IRL (computer science in real life) project to introduce the concept of algorithm to absolute beginners that wonder about our science. More information at http://www.loria.fr/~quinson/Mediation/SMN/ (in French).

You should try to first move the largest pancake to the bottom, and then the largest but one pancake on top of it, and then the one just smaller on top, and so on.

So first, you need to move the largest pancake at the bottom of the stack.
Can you imagine a situation in which you can easily bring this damn large pancake to the bottom?
How could you reach this situation from the current one?