Exercise 3 solution from collections import deque def hot_potato(names, k): d = deque(names) removed = [] while len(d) > 1: d.rotate(-(k - 1)) # bring the k-th person to the front removed.append(d.popleft()) return removed, d[0] print(hot_potato(["Ann", "Bob", "Cy", "Dee", "Eve"], 3)) Output: (['Cy', 'Ann', 'Eve', 'Bob'], 'Dee') By hand: counting 3 from Ann gives Cy, who is out. Counting restarts at Dee: Dee, Eve, Ann -> Ann is out. Restart at Bob: Bob, Dee, Eve -> Eve is out. Restart at Bob: Bob, Dee, Bob -> Bob is out. Dee is left. rotate(-(k - 1)) moves the first k-1 people to the back, so the k-th person is now at the front and popleft() removes them. The order of the remaining people is preserved around the ring.