RosettaCodeData/Task/Pancake-numbers/00-TASK.txt

16 lines
1.6 KiB
Plaintext

Adrian Monk has problems and an assistant, Sharona Fleming. Sharona can deal with most of Adrian's problems except his lack of punctuality paying her remuneration. Two pay checks down and she prepares him pancakes for breakfast. Knowing that he will be unable to eat them unless they are stacked in ascending order of size she leaves him only a skillet which he can insert at any point in the pile and flip all the above pancakes, repeating until the pile is sorted. Sharona has left the pile of n pancakes such that the maximum number of flips is required. Adrian is determined to do this in as few flips as possible. This sequence n->p(n) is known as the Pancake numbers.
The task is to determine p(n) for n = 1 to 9, and for each show an example requiring p(n) flips.
[[Sorting_algorithms/Pancake_sort]] actually performs the sort some giving the number of flips used. How do these compare with p(n)?
Few people know p(20), generously I shall award an extra credit for anyone doing more than p(16).
; Warning: It is known that p(19) is 22 (see in particular the discussion at [https://oeis.org/A058986 A058986]); thus any algorithm that claims otherwise must be treated with caution.<br>
: Note that the original "cheeky partial answer" of [[Pancake_numbers#Phix|Phix]] has since been updated (5/12/2020), and/but just that, with no examples as asked for, ''will'' get your entry marked as incomplete.
;References
# [https://web.archive.org/web/20240525075316/https://www.bbvaopenmind.com/en/science/mathematics/bill-gates-and-the-pancake-problem/ Bill Gates and the pancake problem]
# [https://oeis.org/A058986 A058986]
<br><br>