Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace judge
- {
- class judge
- {
- static void Main(string[] args)
- {
- List<string> cards = Console.ReadLine().Split(' ').Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
- int count = 0;
- int prevValue = -1;
- int sum = 0;
- for (int i = 0; i < cards.Count; i++)
- {
- int value = CardValue(cards[i]);
- if (value == prevValue)
- {
- count++;
- }
- else
- {
- count = 1;
- }
- sum = sum + value;
- if (count == 2)
- {
- sum = sum + 2 * value;
- }
- if (count > 2)
- {
- sum = sum + value;
- }
- prevValue = value;
- }
- Console.WriteLine(sum);
- }
- static int CardValue(string card)
- {
- if (card[0] == '2')
- {
- return 2;
- }
- else if (card[0] == '3')
- {
- return 3;
- }
- else if (card[0] == '4')
- {
- return 4;
- }
- else if (card[0] == '5')
- {
- return 5;
- }
- else if (card[0] == '6')
- {
- return 6;
- }
- else if (card[0] == '7')
- {
- return 7;
- }
- else if (card[0] == '8')
- {
- return 8;
- }
- else if (card[0] == '9')
- {
- return 9;
- }
- else if (card.Substring(0, 2) == "10")
- {
- return 10;
- }
- else if (card[0] == 'J')
- {
- return 12;
- }
- else if (card[0] == 'Q')
- {
- return 13;
- }
- else if (card[0] == 'K')
- {
- return 14;
- }
- else if (card[0] == 'A')
- {
- return 15;
- }
- else
- {
- return 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement