use the code from <Beauty of Programming> book implement the pile of cancake problem which is also named sorting prefix reverse