PROBLEM 2: Take Two [20 points]
Now that you¡¯ve become proficient at playing the game, we will start adding in extra rules. For this one, if a player plays any ¡°two¡± card (R2, Y2, G2 or B2), the next player¡¯s turn is skipped and they must take two cards. You will apply the Rule of Two below:
Rule of Two
If the card last laid in the discard pile was numbered 2, the next player must choose between the following options:
¡ì If they have another ¡°two¡± card (R2, Y2, G2 or B2) in their hand, they will choose to play the one.
o If they have more than one colour, they will pick in rainbow order: red- yellow-green-blue.
¡ì If they do not have a ¡°two¡± card, on their turn they are skipped and must draw two cards from the top of the draw pile.
Input
Same as in Problem 1.
Processing
Same as in Problem 1 with the following exception:
¡ì If a player lay¡¯s down a card numbered 2, the next player must apply the Rule of Two as described above.
Output format
Same as in Problem 1 with the following exception:
¡ì If a player lay¡¯s down a card numbered 2 and the following player is unable to play another ¡°two¡± card, output:
{N}: TAKE TWO
Where N = 1,2, or 3, the skipped player that had to draw two cards.
HINT: Start from Problem 1 and modify…
6
Sample input
Sample output
New hand after play
R1 R4 Y6 G8 B2
R2 R8 Y7 Y8 B3
R3 R6 Y3 G4 G5
B6
Y2 B7 Y1 G6 Y5 G7
… R5R7G1Y4B5
… G3B1B8B4G2
0: B6
1: B2
2: R2
3: TAKE TWO
1: R1
2: R8
3: R3
1: R4
2: DRAW
3: R6
1: Y6
2: Y1
3: Y2
1: TAKE TWO
2: Y7
3: Y3
1: Y5
2: Y8
3: DRAW
1: G8
2: DRAW
3: G4
1: G6 (WINNER)
—
1: R1 R4 Y6 G8 B2
2: R2 R8 Y7 Y8 B3
3: R3 R6 Y2 Y3 G4 G5 B7 1: R1 R4 Y6 G8
2: R8 Y7 Y8 B3
3: R3 R6 Y2 Y3 G4 G5 B7 1: R4 Y6 G8
2: Y1 Y7 Y8 B3
3: R6 Y2 Y3 G4 G5 B7
1: Y6 G8
2: Y1 Y7 Y8 B3
3: Y2 Y3 G4 G5 B7
1: Y5 G6 G8
2: Y7 Y8 B3
3: Y3 G4 G5 B7
1: Y5 G6 G8
2: Y8 B3
3: G4 G5 G7 B7
1: G6 G8
2: R5 B3
3: G4 G5 G7 B7
1: G6
7