In an American football game, two teams compete to get the most points and there are six ways to score these points. We'll give each an abbreviation:
- Field goal -
FG: 3 points
- Touchdown -
TD: 6 points
- Extra point -
XP: 1 point - Can only be scored directly after a touchdown.
- Two-point conversion -
XD(like an extra point but happier): 2 points - Can only be scored directly after a touchdown.
- Safety -
S: 2 points
- Fair catch kick -
FCK: 3 points (a very rare play)
Write a program or function that takes in a single line string containing only these six abbreviations, in both uppercase and lowercase.
This string represents all the scoring events in a game (or portion of a game) of football, with the uppercase terms belonging to one team and the lowercase belonging to the other.
Your job is to report the final scores of the game and indicate who won with output of the form
[score 1] [to] [score 2]
[score 1]is always the larger of the two scores (if not equal), regardless of if uppercase or lowercase won.
[score 2]is the smaller of the two scores (if not equal).
TOif the uppercase team won,
toif the lowercase team won, and
Toif it's a tie.
28 TO 24
- Your program/function must support any arbitrary input, including the empty string.
XDwill only occur right after
xdwill only occur right after
- You may not assume the input string starts or ends in a certain case.
- A single trailing newline is optionally allowed in both the input and output
The shortest code in bytes wins. Answers that are posted before the kickoff (too late now!) of Super Bowl 50 may predict the winning team (either Panthers or Broncos), and if they are correct, get a -10% byte bonus!
(I will check revision history to ensure predictions have not changed and really were made before kickoff.)
[empty string] -> 0 To 0 TDXPtdxpTDXPtdxpfgtdxpTDXPTDXP -> 28 TO 24 FG -> 3 TO 0 fg -> 3 to 0 TD -> 6 TO 0 td -> 6 to 0 TDXP -> 7 TO 0 tdxp -> 7 to 0 TDXD -> 8 TO 0 tdxd -> 8 to 0 S -> 2 TO 0 s -> 2 to 0 FCK -> 3 TO 0 fck -> 3 to 0 TDTDXDSssFCKfgfckFGtd -> 22 TO 16 fcksFCKS -> 5 To 5 tdtdtdtdxp -> 25 to 0 SSSSSSSTD -> 20 TO 0 fgSfckFGfgtdxptdxdTDs -> 26 to 11 FGTDXPtdxdtdsStdxpfgTDfckTDXDFCK -> 29 To 29