Професионална програма
Loading...
+ Нов въпрос
GIlchev95 avatar GIlchev95 0 Точки

05. Card Game - Associative Arrays

Здравейте, Judge ми дава 40/100 със следното решение - https://pastebin.com/CbhVPB7J - грешките са на 1,2 и 6ти тест. Блъскам си главата сума време и не виждам (предполагам очевидната) си грешка. Благодаря предварително

Тагове:
0
JavaScript Fundamentals
svephoto avatar svephoto 1059 Точки

Здравей, GIlchev95,

 

Би ли дал и условието на задачата?

0
GIlchev95 avatar GIlchev95 0 Точки

Card Game
You are given a sequence of people and for every person what cards he draws from the deck. The input will be array of strings. Each string will be in the format:
{personName}: {PT, PT, PT,… PT}
Where P (2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A) is the power of the card and T (S, H, D, C) is the type. The name can contain any ASCII symbol except ':'. The input will always be valid and in the format described, there is no need to check it.
A single person cannot have more than one card with the same power and type, if he draws such a card he discards it. The people are playing with multiple decks. Each card has a value that is calculated by the power multiplied by the type. Powers 2 to 10 have the same value and J to A are 11 to 14. Types are mapped to multipliers the following way (S -> 4, H-> 3, D -> 2, C -> 1).
Finally print out the total value each player has in his hand in the format:
{personName}: {value}
Examples

Input    [
'Peter: 2C, 4H, 9H, AS, QS',
'Tomas: 3H, 10S, JC, KD, 5S, 10S',
'Andrea: QH, QC, QS, QD',
'Tomas: 6H, 7S, KC, KD, 5S, 10C',
'Andrea: QH, QC, JS, JD, JC',
'Peter: JD, JD, JD, JD, JD, JD'
]

Output

Peter: 167
Tomas: 175
Andrea: 197


[
'John: 2C, 4H, 9H, AS, QS',
'Slav: 3H, 10S, JC, KD, 5S, 10S',
'Alex: 6H, 7S, KC, KD, 5S, 10C',
'Thomas: QH, QC, JS, JD, JC',
'Slav: 6H, 7S, KC, KD, 5S, 10C',
'Thomas: QH, QC, JS, JD, JC',
'Alex: 6H, 7S, KC, KD, 5S, 10C',
'Thomas: QH, QC, JS, JD, JC',
'John: JD, JD, JD, JD'
]    

John: 167
Slav: 175
Alex: 115
Thomas: 125
 

0