In the game of Hot Potato, a circle of people pass around a "hot potato" until some amount of time has passed. At that point, the person holding the potato is out. Play continues until there is only one person remaining, who is the winner.
Write a program hot_potato.py
that takes a list of people who are considered to be standing in a circle. Place them in a queue, and has them pass a virtual "hot potato" around until everyone but one person has been removed from the queue.
Key question: How to manipulate a linear sequence of items in a "circular" fashion?
Here's the queue:
Queue[Streak,Michael,Jonah,Eddie,Nicholas,Maaso,Grayson]
Grayson has the potato!
Maaso has the potato!
Nicholas has the potato!
Eddie has the potato!
Jonah has the potato!
Michael is out!
([Enter] to see the next round!)
Here's the queue:
Queue[Jonah,Eddie,Nicholas,Maaso,Grayson,Streak]
Streak has the potato!
Grayson has the potato!
Maaso has the potato!
Nicholas has the potato!
Eddie has the potato!
Jonah is out!
([Enter] to see the next round!)
Here's the queue:
Queue[Eddie,Nicholas,Maaso,Grayson,Streak]
Streak has the potato!
Grayson has the potato!
Maaso has the potato!
Nicholas has the potato!
Eddie has the potato!
Streak is out!
([Enter] to see the next round!)
Here's the queue:
Queue[Eddie,Nicholas,Maaso,Grayson]
Grayson has the potato!
Maaso has the potato!
Nicholas has the potato!
Eddie has the potato!
Grayson has the potato!
Maaso is out!
([Enter] to see the next round!)
Here's the queue:
Queue[Grayson,Eddie,Nicholas]
Nicholas has the potato!
Eddie has the potato!
Grayson has the potato!
Nicholas has the potato!
Eddie has the potato!
Grayson is out!
([Enter] to see the next round!)
Here's the queue:
Queue[Eddie,Nicholas]
Nicholas has the potato!
Eddie has the potato!
Nicholas has the potato!
Eddie has the potato!
Nicholas has the potato!
Eddie is out!
([Enter] to see the next round!)
Nicholas is the winner!