CCC '99 S1 - Card Game

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Problem type

Write a program that will keep score for a simple two-player game, played with a deck of cards. There are 52 cards in the deck; four of each of 13 possible names: two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace. The cards labelled jack, queen, king, and ace are collectively known as high cards.

The deck is shuffled and placed face-down on the table. Player A turns over the top card and places it on a pile; then player B turns over the top card and places it on the pile. A and B alternate until the deck is exhausted. The game is scored as follows:

  • If a player turns over an ace, with at least 4 cards remaining to be turned over, and none of the next 4 cards is a high card, that player scores 4 points
  • If a player turns over a king, with at least 3 cards remaining to be turned over, and none of the next 3 cards is a high card, that player scores 3 points
  • If a player turns over a queen, with at least 2 cards remaining to be turned over, and none of the next 2 cards is a high card, that player scores 2 points
  • If a player turns over a jack, with at least 1 card remaining to be turned over, and the next card is not a high card, that player scores 1 point

Input Specification

The input will contain 52 lines. Each line will contain the name of a card in the deck, in lowercase letters. The first line denotes the first card to be turned over; the next line the next card; and so on.

Output Specification

Whenever a player scores, print Player X scores n point(s). where X is the name of the player (A or B) and n is the number of points scored (1, 2, 3, or 4). At the end of the game, print the total score for each player, on two lines:

Player A: n point(s).
Player B: m point(s).

Sample Input

three
seven
queen
eight
five
ten
king
eight
jack
queen
six
queen
jack
eight
seven
three
ten
four
king
nine
six
seven
ace
four
jack
ace
ten
nine
ten
queen
ace
king
seven
two
five
two
five
nine
three
king
six
eight
jack
six
five
four
two
ace
four
three
two
nine

Sample Output

Player A scores 2 point(s).
Player A scores 1 point(s).
Player A scores 3 point(s).
Player B scores 3 point(s).
Player A scores 1 point(s).
Player B scores 4 point(s).
Player A: 7 point(s).
Player B: 7 point(s).

Comments


  • 0
    mrap  commented on July 22, 2024, 4:56 p.m.

    The test "none of the next n cards is a high card" requires looking at the next n cards. They ought to then be eliminated from play. Would make the solution more involved too. Besides, what game is it if the next n cards are now known? :)


  • 0
    macOSbyApple  commented on March 20, 2023, 4:33 p.m.

    bruh I went through the extra effort of deciding point or points depending on how many points, and then found out that you just need point(s)


  • -5
    GD_FrostByte  commented on Dec. 16, 2018, 2:44 p.m. edit 5

    This comment is hidden due to too much negative feedback. Show it anyway.


    • -7
      poesis11  commented on Sept. 19, 2021, 10:08 a.m. edited

      This comment is hidden due to too much negative feedback. Show it anyway.


      • 8
        replae  commented on Nov. 8, 2021, 1:00 a.m.

        the judge cuts it off so you dont get the full result of your solution