UVa 11459

From Algorithmist
Jump to navigation Jump to search

11459 - Snakes and Ladders[edit]

Summary[edit]

Simulation of the game "Snakes and Ladders" ("Chutes and Ladders" to Americans).

Explanation[edit]

Straightforward simulation.

Gotchas[edit]

  • Make sure you end the game immediately when someone wins, be it from reaching or exceeding square 100 on the die roll or reaching 100 by a ladder.
  • Even if the game is won, you need to read in the remaining die rolls.

Implementations[edit]

  • Even though the problem tells you to accommodate a million players, a thousand is adequate.

Input[edit]

2
4 1 10
5 100
2
6
4
5
2
6
2
3
4
1
2 1 3
4 99
3
4
6

Output[edit]

Position of player 1 is 3.
Position of player 2 is 7.
Position of player 3 is 100.
Position of player 4 is 1.
Position of player 1 is 100.
Position of player 2 is 5.