Rotate a queue to eliminate players
A queue serves items in arrival order. collections.deque removes from the front in constant time, unlike list.pop(0), which shifts every remaining item.
from collections import deque
line = deque(["Ann", "Bob", "Cy"])
line.rotate(-1)
print(line) # deque(['Bob', 'Cy', 'Ann'])Think before coding
Passing the item k times is the same as moving k people from the front to the back. The person now at the front is out. Repeat until the queue is empty, recording the order people leave. Work through the example by hand before changing the starter. Decide what should happen for an empty input, a single value and a repeated value where those cases apply. The checks use several inputs so a hard-coded answer cannot stand in for the rule.
Your task
Write elimination_order(names, k): pass k times around the queue, remove whoever is at the front, and repeat. Return the names in the order they leave. Do not modify names.
The explanation opens here once every check passes.