A higher resolution is required to access the IDE
- 160
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Your goal is to recreate a simplified turns prediction for the Monopoly™ game.You'll be given a list of players with their names and their initial positions, a list of dice rolls, and a list of names of all the game board positions. You'll need to find the latest position for each player after all the given dice rolls.
GAME BOARD
The game is played on a circular game board.
There are 40 positions on the board, indexed from
BASIC RULES
Each player rolls two dice, and moves forward
Multiple players can occupy the same position.
If a player reaches position
Unless something special happens (see below), his turn ends after moving.
DOUBLE RULES
A double refers to a roll where both dice have the same value.
If the player rolls a double, then he rolls the dice and moves again.
If the player rolls a double three times in a row, then he immediately goes to jail (see below) and his turn ends there.
JAIL RULES
The
If at the end of a basic move, the player lands on
If the player rolls a double for the third time in a single turn, then he immediately moves to the position
If after moving, the player lands on
While the player is in jail, he still rolls the dice on his turn as usual, but doesn't move until either:
(a) he rolls a double, or
(b) he fails to roll a double for three throws (i.e. his previous two turns after moving to jail and his current turn).
If either (a) or (b) happens in the player's turn, then he moves forward
Note:
Input
Line 1: An integer P for the number of players
Next P lines: One line for each player, containing the name and the initial position, separated with a space
Next line: An integer D for the number of dice rolls in playing order
Next D lines: One line for each dice roll (space-separated)
Next 40 lines: One line for the name of each board position. Note that these aren't actually needed to solve the puzzle.
Next P lines: One line for each player, containing the name and the initial position, separated with a space
Next line: An integer D for the number of dice rolls in playing order
Next D lines: One line for each dice roll (space-separated)
Next 40 lines: One line for the name of each board position. Note that these aren't actually needed to solve the puzzle.
Output
P lines: One line for each player, containing the name and the latest position, separated with a space. The output should follow the same order of the players as given in the input.
Constraints
2 ≤ P ≤ 6
Players' names do not contain any spaces.
Players never start onGo To Jail or in jail.
The game board is constant.
Players' names do not contain any spaces.
Players never start on
The game board is constant.
Example
Input
2 Horse 0 TopHat 0 6 1 6 2 1 6 4 2 1 4 5 6 5 Go Mediterranean Avenue Community Chest Baltic Avenue Income Tax Reading Railroad Oriental Avenue Chance Vermont Avenue Connecticut Avenue Visit Only / In Jail St. Charles Place Electric Company States Avenue Virginia Avenue Pennsylvania Railroad St. James Place Community Chest Tennessee Avenue New York Avenue Free Parking Kentucky Avenue Chance Indiana Avenue Illinois Avenue B. & O. Railroad Atlantic Avenue Ventnor Avenue Water Works Marvin Gardens Go To Jail Pacific Avenue North Carolina Avenue Community Chest Pennsylvania Avenue Short Line Chance Park Place Luxury Tax Boardwalk
Output
Horse 26 TopHat 17
A higher resolution is required to access the IDE