Question: The second task in this assignment is to create a Python program called pancakes.py that will determine the final order of a stack of pancakes

The second task in this assignment is to create a Python program called pancakes.py that will determine the final order of a stack of pancakes after a series of flips.PYTHON 3)

Problem Task

In this problem, your input will consist of an integer n, followed by some number of other integers. You will create an initial stack of n pancakes, with pancake 1 on top and pancake n on the bottom. Then for each k in the remaining set of integers in the input, you will flip the top k pancakes on the top of the stack.

Hint: try using the Stack ADT in your solution.

Your program must read the input from an input file (see sample input provided for format), and print the final order of pancakes from top to bottom. Your program should ask for the name of the input file when it runs.

Sample Input

11 5 2 10

Sample Output

10 9 8 7 6 1 2 3 5 4 11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!