Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hot Potato
- There are N people seated at a round table. A hot potato is placed on the table.
- The potato is passed clockwise around the table to M-1 people. The Mth person
- to receive the potato leaves the table. The potato is then passed again.
- This procedure is repeated until the table is empty. The last person to leave
- is the winner.
- Diagram of the Hot Potato solution when N = 9 and M = 5
- 1 2 3 4 5 6 7 8 9 remove 5
- 1 2 3 4 6 7 8 9 remove 1
- 2 3 4 6 7 8 9 remove 7
- 2 3 4 6 8 9 remove 4
- 2 3 6 8 9 remove 3
- 2 6 8 9 remove 6
- 2 8 9 remove 9
- 2 8 remove 2
- 8 winner
- Write a computer program to simulate the hot potato game. Given values
- for N and M as inputs, it should produce a display like the one above.
Advertisement
Add Comment
Please, Sign In to add comment