## CCO '04 P6 - Orko

View as PDF

Points: 15
Time limit: 1.0s
Memory limit: 32M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### Canadian Computing Competition: 2004 Stage 2, Day 2, Problem 3

Orko is a two-player card game. Each card has a colour (Red, Yellow, Green, or Black) and a value (1, 2, 3, 4, or 5). The deck contains twenty cards; one card having each distinct combination of colour and value.

Each player is dealt ten of the twenty cards. The game is played in ten rounds, and the objective is to win as many rounds as possible. In each round, one player, the player with 'the lead', plays one of his cards. The other player must play a card of the same colour, if he has one. If not, he may play any of his cards. The player with the lead wins the round if the other player has no card of the same colour, of if his card has a higher value. Otherwise the other player wins the round.

The objective of the game is to win as many rounds as possible. The lead for the first round is chosen arbitrarily; the lead for each subsequent round is given to the winner of the previous round.

Your job is to determine how many rounds each player will win, assuming that each player employs the strategy that maximizes his advantage.

#### Input Specification

The input contains several test cases. Each test case consists of one line of input, identifying the cards dealt to one of the players, Player . Each card is identified by a letter (R,Y,G,B) denoting its colour followed by a digit denoting its value (1,2,3,4,5). The other player, Player receives the remaining cards in the deck. A line containing

* * * * * * * * * * *

( stars, separated by spaces) follows the last test case.

#### Output Specification

For each test case, output a single line giving an integer between and , the number of rounds won by Player . Assume that Player has the lead for the first round.

#### Sample Input

G1 G3 B2 R2 Y1 R3 R5 Y2 Y3 G5
* * * * * * * * * *

#### Sample Output

3

is this supposed to be or instead of of?