#P2117. ACSL 2024-2025 Senior Division Contest #2 Uno Duo
ACSL 2024-2025 Senior Division Contest #2 Uno Duo
PROBLEM DESCRIPTION
The card game Duo uses cards that have characteristics: a color, number, and symbol. The game starts with two face-up cards and cards in the player’s hand. On a single turn, the player can choose one of the two face-up cards and match as many cards from their hand as possible, thus making a pile. A card can be placed on top of another card if exactly of the characteristics match.

The ACSL cards use four colors (R=red, Y=yellow, G=green, B=blue), four numbers (1, 2, 3, 4), and four symbols (X=cross, O=circle, S=square, T=triangle). A card is represented by a -character string showing the color, number, and symbol, in that order. For example, the card R4S, shown on the left, is red with the number 4 and contains a square. There are cards that could possibly be placed on top of this card: a red square with the number 1, 2, or 3; a yellow, green, or blue square with the number 4; a red cross, circle, or triangle with the number 4.


The deck of cards may also have “wild” cards that have just of these characteristics and would be represented as a string such as a color (e.g. G) or a number (e.g. 3), or a shape (e.g. S). These cards can be matched if that one characteristic matches the other card’s same characteristic, regardless of what the other two characteristics are.
Your program will play multiple turns of Uno Duo for a single player. The turn begins with two face-up cards, cards in the hand (think of them as being held from left to right), and a draw pile.
- Find the leftmost card in your hand that matches one of the face-up cards. Place the matched card on that face-up card, creating a pile. If the card matches both face-up cards, choose the first card.
- Try to match as many cards as you can in your hand on that pile. Each time, look at your cards starting at the leftmost card.
- If a Wild Card is at the top of the pile, play the first card that matches it.
- Your turn is over when there are no more cards in your hand or you cannot play any of them.
When your turn is over, add as many cards as possible from the draw pile so that you have no more than cards in your hand. Continue with another turn until you've played all the cards in your hand and the draw pile is empty, or no cards can be matched. Output the number of cards in your hand, followed by the top card in each pile. Separate each by a single space.
INPUT FORMAT
There will be three strings: the face-up cards; the cards in the player’s hand; and the cards in the draw pile. There will be no more than cards in the draw pile. All cards are separated by a single space.
OUTPUT FORMAT
Output a string containing the number of cards that are left in the player’s hand, the top card on Pile #1 and the top card on Pile #2, each separated by a single space.
SAMPLE
INPUT #1
R4S B3O
R3X T B1T R1X B3X B1X Y4O
B4X Y3O B4T G2X B B3T
OUTPUT #1
3 R4S B3T
INPUT #2
G4T Y2S
B4O G4X B1O G4O R4O R1O 1
Y2T G3T Y4O G2T Y2O
OUTPUT #2
1 Y2O G3T
INPUT #3
R4T R3T
G2S R4X B3O Y3X G3S Y3S Y4X
B3T Y1T Y2T Y2O G2O B1T Y2S B2X B4X B2S Y1S R1O B1X B4S Y4S
OUTPUT #3
1 Y4S B3O
INPUT #4
G2X Y1X
Y2O Y4T G2T B2O B2T Y3O B3X
B1T B3O B1X G2S B1O G1X Y3S R3S Y1S B3S
OUTPUT #4
6 B1O G1X
INPUT #5
G4O B1T
4 B1O R4T B4T B3T B4X G1O
G2S Y3T S R4S Y4S R Y
OUTPUT #5
3 G2S G1O
INPUT #6
G2S B1T
Y1X Y3O G4T 1 G4O B4T Y2X
R4T S B1S B1O R2T B3T O G1O G3O R1O R1X
OUTPUT #6
7 B1O Y2X
EXPLANATION
Sample #1 Explanation
Initially, the two face-up cards and the cards in the hand are as follows:

The first card in the hand that can be played is B3X (matching the color and the number, but not the shape) on the nd face-up card, thus making a pile. All future matches in this turn must go on the nd pile.

The next moves are as follows:

At this point, the only card remaining in the hand is Y4O. It cannot be placed on Pile #2, so the turn ends. The hand needs to be replenished with cards from the draw pile so the player’s hand is now: Y4O B4X Y3O B4T G2X B B3T

On the next turn, choose Pile #2 with the card B4T. Then play B4X, B, and B3T in that order. Since the Draw Pile is empty, the game ends.

There are unplayable cards left in the hand (Y4O, Y3O, and G2X) and the
draw pile is empty. The top cards in the piles are R4S on Pile #1 and B3T on Pile #2. The output is the string: 3 R4S B3T.