PythiloLesson 6 of 32 · progress kept in this browser

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'])
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.