http://programmingpraxis.com/2009/04/07/flipping-pancakes/