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.Threading.Tasks;
- namespace _05.HandsOfCards
- {
- class Program
- {
- static int sum(List<string>a)
- {
- int n = 0;
- for(int i=0;i<a.Count();i++)
- {
- int s = 0;
- switch(a[i][0])
- {
- case '2':s = 2;break;
- case '3': s = 3; break;
- case '4': s = 4; break;
- case '5': s = 5; break;
- case '6': s = 6; break;
- case '7': s = 7; break;
- case '8': s = 8; break;
- case '9': s = 9; break;
- case '1': s = 10; break;
- case 'J': s = 11; break;
- case 'Q': s = 12; break;
- case 'K': s = 13; break;
- case 'A': s = 14; break;
- }
- int t = 1;
- if (a[i][0] == '1') t++;
- switch(a[i][t])
- {
- case 'S':s = s * 4;break;
- case 'H': s = s * 3; break;
- case 'D': s = s * 2; break;
- case 'C': s = s * 1; break;
- }
- n = n + s;
- }
- return n;
- }
- static void Main(string[] args)
- {
- var a = Console.ReadLine().Trim().Split(new char[] { ':', ' ', ',' }).ToArray();
- //Console.WriteLine(string.Join(",", a));
- var cards = new Dictionary<string, List<string> > ();
- while(a[0]!="JOKER")
- {
- // Console.WriteLine(a[0]);
- for(int i=1;i<a.Length;i++)
- {
- if(a[i]!="")
- {
- // Console.WriteLine(a[i]);
- if (cards.ContainsKey(a[0])) { if (!cards[a[0]].Contains(a[i])) cards[a[0]].Add(a[i]); }
- else cards.Add(a[0], new List<string> { a[i] });
- }
- }
- a = Console.ReadLine().Trim().Split(new char[] { ':', ' ', ',' }).ToArray();
- }
- foreach(var n in cards)
- {
- Console.WriteLine($"{n.Key}: {sum(n.Value)}");
- //Console.WriteLine(string.Join(",", n.Value));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement