CCC '01 S1 - Keeping Score

View as PDF

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

Problem type
Canadian Computing Competition: 2001 Stage 1, Junior #3, Senior #1

In a card game, each player's hand is made up of cards. Each hand has a total point value determined by the number of cards that have a point value. The cards which are worth points are the Ace ( points), King ( points), Queen ( points) and Jack ( point). The other cards (2, 3, 4, 5, 6, 7, 8, 9, 10) have no point value.

There are four of each type of card, one in each of the four suits. The suits are called clubs (C), diamonds (D), hearts (H), and spades (S). As well, points are assigned for each suit which has a void ( points), a singleton ( points), or a doubleton ( point). A void in a suit means that there are no cards of that suit (e.g. a hand with no spades). A singleton in a suit means that there is only one card in that suit (e.g. a hand with only one diamond). A doubleton in a suit means that there are only two cards in that suit.

Write a program to read a set of thirteen cards in the form of a string, then evaluate the number of points in the hand. The suits will appear in increasing alphabetical order. Within each suit there will be no duplicate cards.

The output is to be the hand and the point value shown in a table form as below. Your output should list the cards in the same order as the input. Note that 10 is represented by the character T in both the input and the output.

Sample Input 1

C258TJKD69QAHSTJA

Sample Output 1

Cards Dealt              Points
Clubs 2 5 8 T J K             4
Diamonds 6 9 Q A              6
Hearts                        3
Total 18

Sample Output 2

Cards Dealt              Points
Clubs A                       6
Diamonds 5 7 8 K A            7
Hearts A                      6
Spades 4 7 T Q K A            9
Total 28

Note: your output does not need to match exactly. The spacing is up to you.

• commented on Jan. 27, 2021, 5:14 a.m.

Hello, does anyone know why my code receives a "WA" on test case 1? Thanks in advance!

• commented on June 4, 2021, 12:13 a.m.

I had the same problem, consider what happens when all the cards are in the same suit.

• commented on Aug. 19, 2020, 4:06 p.m. edited

I get WA, but the 2 test cases work, any help? edit: nvm fixed it

• commented on July 9, 2020, 6:22 p.m. edit 2

bruh why testcase 2 wrong

• commented on Feb. 5, 2021, 3:20 p.m.

i'm having the same issue.

• commented on Jan. 31, 2020, 4:32 p.m.

WA: Can anyone take a look at my submission? The samples are right but I have the spacing wrong. Shouldn't matter though

• commented on Sept. 25, 2019, 9:58 p.m. edit 3

For those of you who are confusing due to the constantly feedback of WR but the code works fine --- spacing doesn't matter, but you NEED AT LEAST 1 spacing in order to make it works

• commented on Oct. 22, 2018, 4:02 p.m.

Would anyone mind taking a look at my program? First of all, I don't know if formatting the spacing is necessary. Second, because the output was clipped, I am not sure where I got it wrong, but it seems like the point for the club are right.

• commented on Oct. 22, 2018, 4:18 p.m. edit 2

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Oct. 25, 2018, 2:26 p.m.

"Note: your output does not need to match exactly. The spacing is up to you."

positioning does not matter, can confirm

• commented on May 25, 2018, 8:54 p.m. edited

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 9, 2018, 7:56 p.m.

WA

• commented on Jan. 9, 2018, 9:55 p.m.

Compare your last line of output(The "Total Points" one) to the sample Output, you will know the reason xD

• commented on March 1, 2020, 7:12 p.m.

Lmao printed total #of cards instead of #points!

• commented on June 26, 2017, 9:59 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on June 29, 2017, 6:38 p.m.

Your code seems over complicated, just process the string letter by letter,printing out the cards and tracking points. When you encounter a new suit, as in a "D","H", or "S", print out the info you've been holding, wipe your variables, and keep going, this time on another suit.

• commented on Feb. 12, 2017, 7:14 p.m.

WA Can someone take a loot at my submission? It seems right but the spacing seems to be off

• commented on Feb. 12, 2017, 8:16 p.m.

You are printing pts[0] for each suit.

• commented on Feb. 10, 2017, 8:31 p.m. edit 2

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 5, 2017, 12:12 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 5, 2017, 1:31 p.m. edited

The cards should be space separated.

E.g. Diamonds 5 7 8 K A

You also misspelled Clubs

• commented on Oct. 7, 2018, 2:15 a.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 6, 2017, 11:41 a.m.

Thanks

• commented on Nov. 3, 2016, 4:25 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Nov. 3, 2016, 6:58 p.m.

Declare a larger buffer, 4096 is a commonly used number.