Under construction

Still being built. Things may change

Card Game Score

Interview

Time limit1sMemory limit128 MB

Summary
Given five playing cards with color and number, compute a poker-like score by checking a fixed priority list of hand patterns.
Level

Easy3 of 10

Topics
Simulation, Implementation, Hash map
Solved
No attempts yet

Problem

A card game uses 36 cards. Each card has one of four colors, R, B, Y, or G, and one number from 1 through 9. There are nine cards of each color.

Five cards are given. Compute the score by applying the highest-scoring rule that matches the hand.

RuleScore
All five cards have the same color and their numbers are consecutive.900 + highest number
Four cards have the same number.800 + that number
Three cards have one number, and the remaining two cards have another number.700 + (number on the three cards) * 10 + (number on the two cards)
All five cards have the same color.600 + highest number
The five card numbers are consecutive.500 + highest number
Three cards have the same number.400 + that number
Two cards have one number, and another two cards have another number.300 + (larger paired number) * 10 + (smaller paired number)
Two cards have the same number.200 + that number
None of the rules above applies.100 + highest number

If more than one rule applies, the card game's score is the highest possible score.

Input

Five lines are given. Each line contains one card's color and number separated by a single space.

Output

Print the card hand's score on one line.

Examples1

  1. Example 1

    Input
    B 3
    B 7
    R 1
    B 2
    Y 7
    
    Expected output
    207