Problem 42498. Pancake sorting - minimum flips.
Sort a stack of pancakes by flipping them using spatula.
- There are N pancakes with diameters 1:N.
- Spatula can be inserted anywhere in the stack and used to flip all the pancakes above.
- Sort pancakes in increasing order.
- Return a vector of places where spatula was inserted.
- Minimize number of flips, your score will depend on the number of flips in the last few tests.
- References: math.illinois.edu, wikipedia.
Example (horizontal view):
Initial stack: 6 4 2 5 3 1, ("," indicates position of spatula)
first flip: 1 3 5,2 4 6
second: 5 3 1 2 4,6
... 4 2 1 3,5 6
3 1 2,4 5 6
2 1,3 4 5 6
sorted! 1 2 3 4 5 6
positions of spatula from the begining: 6 3 5 4 3 2
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
Dyuman Joshi
on 18 Oct 2022
Lincoln, I checked the reference solution and it showed that the manual scoring system no longer works.
I will see what changes I can do and notify it here.
Stefan Abendroth
on 26 May 2023
Unfortunately, the scoring system is broken (same as in the TRON challenge by Alfonso).
No way to get the Indexing IV badge :-(
Dyuman Joshi
on 26 May 2023
@Stefan, I have commented out the part that outdated and the test suite is working now.
I have rescored your solution, you can now (hopefully) get the Indexing IV badge!
Solution Comments
Show commentsGroup

Cody5:Easy
- 31 Problems
- 159 Finishers
- Energy of a photon
- Breaking Out of the Matrix
- The Top 5 Primes
- I Plead the Fifth
- Pentagonal Numbers
- Is this is a Tic Tac Toe X Win?
- Inscribed Pentagon?
- Circle/Pentagon Overlap
- Octoberfest festival
- Polarisation
- Missing five
- ASCII Birthday Cake
- Find the nearest prime number
- Extra safe primes
- 5 Prime Numbers
- Is this is a Tic Tac Toe X Win?
- Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.
- MATLAB Counter
- Basic electricity in a dry situation
- How to subtract?
- Pernicious Anniversary Problem
- 5 Prime Numbers
- Is it really a 5?
- The glass half full
- Pi Digit Probability
- A Simple Tide Gauge with MATLAB
- Predicting life and death of a memory-less light bulb
- Write c^3 as sum of two squares a^2+b^2
- Van Eck's Sequence's nth member
- Sums of Multiple Pairs of Triangular Numbers
- Recaman Sequence - I
- Recaman Sequence - II
- Spot the First Occurrence of 5
- Energy of a photon
Problem Recent Solvers30
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!