12 Feb Tuesday 17:00 Python Practice – 22.02.28.
Try to use the queue class to implement a general simulation of Hot Potato. Our program will input a list of names and a number, we call it “num,” to be used for counting. It will return the name of the last person remaining after repetitive counting by num.
To simulate the circle, we will use a queue. Assume that the child holding the potato will be at the front of the queue. Upon passing the potato, the simulation will simply dequeue and then immediately enqueue that child, putting her at the end of the line. She will then wait until all the others have been at the front before it will be her turn again.
After num dequeue/enqueue operations, the child at the front will be removed permanently and another cycle will begin. This process will continue until only one name remains.
The first line is children’s names separated by space, second line is the num
The name of the the last child
Sample Input: Bill David Susan Jane Kent Brad 7 Sample Output: Susan