In [20]:
from random import randrange
from pythonds9.basic.queue import Queue
In [33]:
def hot_potato(namelist):
    simqueue = Queue()
    
    for name in namelist:
        simqueue.enqueue(name)
        
    while simqueue.size() > 1:
        num = randrange(1, 13)  # randomly "stopping the music"
        for i in range(num):
            simqueue.enqueue(simqueue.dequeue())
            
        simqueue.dequeue()
        
    return simqueue.dequeue()
In [32]:
players = ["David", "Susan", "Jane", "Kent", "Brad", "Bill"]

hot_potato(players)
Out[32]:
'Bill'