Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ Hot Potato is a game in which children form a circle and start tossing a hot potato. The counting starts with the
- first kid. Every nth toss the child who is holding the potato leaves the game. When a kid leaves the game, it passes
- the potato to the next kid. This continues until there is only one kid left.
- Create a program that simulates the game of Hot Potato. On the first line you will receive names of kids, separated
- by a single space. On the second line you will receive the nth toss (integer) in which a child leaves the game.
- Print every kid which is removed from the circle in the format "Removed {kid}". In the end, print the only kid left
- in the format "Last is {kid}". """
- from collections import deque
- kids = deque(input().split())
- toss = int(input())
- while not len(kids) == 1:
- for _ in range(toss - 1):
- kids.append(kids.popleft())
- print(f'Removed {kids.popleft()}')
- print(f'Last is {kids[0]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement