Eight pancakes of different sizes ā slide a spatula in below any pancake and the entire stack above flips. Sort largest to bottom in as few flips as possible.
Tap any pancake to flip the entire stack from that pancake up to the top. Goal: arrange the stack so the largest pancake is at the bottom and the smallest is at the top. Your score is the number of flips used ā fewer is better. The game ends the moment the stack is sorted.
Use the bring-to-top, then bring-to-bottom pattern. To put the largest unsorted pancake into its final position, first flip below it to send it to the top, then flip below the entire unsorted portion to send it to the bottom of that portion. That places one pancake correctly per pair of flips ā never more than 2(nā1) flips for n pancakes.
Work from the largest down. Once the bottom is the right pancake, lock that row mentally and never touch it again ā every subsequent flip should be at row 2 or higher. Repeating the bring-to-top + bring-to-bottom pattern up the stack guarantees a finish, and the remaining unsorted portion shrinks by one each time.
Spot the freebies. If two adjacent pancakes are already in correct relative order at the right depth, a single flip can sometimes seat both together. Before mechanically applying the standard algorithm, scan whether the largest unsorted pancake is already on top ā in that case skip the first flip of the pair entirely.
Don't unflip your own work. Every flip below the highest correctly-placed pancake breaks at least one finished position. If your move would touch the bottom-locked portion, you've found a wasted flip. The pancake-sorting bound on 8 cakes is 9 in the worst case; if you're routinely going over 14, you're flipping into the finished tower.