Today your stall got so many customer. because the ticket system is broken, you have to make your own queue system.
in you queue system, you just need to concern 5 functionality:
- show():
to show the queue right now (the first got the order to the last)
- push():
to add new customer to the queue system
- pop()
to remove the customer that been served
- size()
to get how long is the queue
- clear()
to clear the queue
as we know in the queue system, the first one in the queue will got the order first
given snippet code below:
def queue():
Q = []
def show():
pass
def push(v):
pass
def pop():
pass
def size():
pass
def clear():
pass
D = {
#fill the command here
}
for _ in range(n):
line = input()
words = line.split()
cmd = words[0]
##call the command here
n = int(input())
queue()
You can review the slide: 17-functional-prog, for another way to write the same logic.
We encouraged you to utilize lambda expression to learn more about it :D
input integer n to represent how many command will you do,
the following n lines are one of the 5 command:
push x : (x are integer to be pushed), add the customer to the queue (for simplicity, all customer name are a number)
pop : remove the customer that been served from the queue (the one that have been in the queue first)
show
size
clear
depends on the command:
push: output NOTHING
pop: output the number that been pop, if the queue is empty, print empty
show: output the list of the customer in the queue
size: print the size of the queue
clear: empty the queue