#C8518. Total Match Score Calculation
Total Match Score Calculation
Total Match Score Calculation
You are given a series of match results represented as a string consisting of the characters W
(win), L
(loss) and D
(draw). The scoring rules are as follows:
- Win (
W
) is awarded \(3\) points. - Draw (
D
) is awarded \(1\) point. - Loss (
L
) yields \(0\) points.
Your task is to compute the total score corresponding to each match result string. In other words, for each test case you need to calculate the quantity:
\[ \text{score} = 3\times\text{number of W's} + 1\times\text{number of D's} \]The input begins with an integer indicating the number of test cases, followed by one line per test case. Output the calculated score for each test case on a new line.
inputFormat
The first line contains a single integer n (\(1 \le n \le 10^5\)) representing the number of test cases. The following n lines each contain a non-empty string composed only of the characters W
, L
, and D
.
outputFormat
For each test case, output a single integer representing the total score calculated according to the rules given, each on a new line.
## sample5
WWDLD
WLWLW
LLL
DDWW
DDDDDD
8
9
0
8
6
</p>