Python队列 - HotPotato
代码:
from pythonds.basic.queue import Queue def hotPotato(nameList, num): q = Queue() for name in nameList: q.enqueue(name) while q.size() > 1: for i in range(num): q.enqueue(q.dequeue()) # 入队出队的操作很骚,很有趣 q.dequeue() return q.dequeue() print(hotPotato(["zx1", "zx2", "zx3"], 3)) # 位于队首的人拥有热土豆