Players stand in a circle and pass a potato. In each round the potato is passed k times; whoever holds it then is out. The last player left wins.
Model the circle with a queue (Deque<String> implemented by ArrayDeque): the player at the front holds the potato. One pass moves the front player to the back (offer(poll())). After k passes, the front player is removed.
Input. Two integers n (number of players, n ≥ 0) and k (k ≥ 0), then n player names (one word each), in circle order.
Output. If n is 0 print No players. Otherwise, for every elimination print Round r: name is out (r starting at 1), and finally Winner: name.
Input:
5 2
Ann Ben Cat Dan Eve
Output:
Round 1: Cat is out
Round 2: Ann is out
Round 3: Eve is out
Round 4: Ben is out
Winner: Dan