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.RegularExpressions;
- namespace Temp
- {
- class Program
- {
- static void Main(string[] args)
- {
- var inputData = Console.ReadLine();
- List<string> data = new List<string>();
- Dictionary<string, long> players = new Dictionary<string, long>();
- Dictionary<string, List<string>> playersCards = new Dictionary<string, List<string>>();
- //.Split(new char[] { ',',' ',':'}, StringSplitOptions.RemoveEmptyEntries).ToList()
- //
- while (inputData != "JOKER")
- {
- var dist = inputData.Split(new char[] { ',',' ',':' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList();
- var name = inputData.Split(new char[] { ':'}, StringSplitOptions.RemoveEmptyEntries).ToList();
- if (!playersCards.ContainsKey(name[0]))
- {
- playersCards.Add(name[0], dist);
- }
- if (playersCards.ContainsKey(name[0]))
- {
- playersCards[name[0]].InsertRange(0, dist);
- playersCards[name[0]].Distinct();
- }
- inputData = Console.ReadLine();
- }
- long type = 0;
- long power = 0;
- long sum = 0;
- foreach (var item in playersCards)
- {
- foreach (var i in item.Value.Distinct())
- {
- var tempA = i;
- var first = "";
- for (int j = 0; j < i.Length-1; j++)
- {
- first += i[j];
- }
- var last = Convert.ToString(i[i.Length-1]);
- if (last == "S" || last == "H" || last == "D" || last == "C")
- {
- if (last == "S")
- {
- type = 4;
- }
- if (last == "H")
- {
- type = 3;
- }
- if (last == "D")
- {
- type = 2;
- }
- if (last == "C")
- {
- type = 1;
- }
- }
- if (first =="2" ||first =="3"||first =="4"||first =="5"||first=="6"||first=="7"||first == "8"||first=="9"||first=="10"||
- first == "J"||first =="Q"||first == "K"||first=="A")
- {
- if (first=="2")
- {
- power = 2;
- }
- if (first == "3")
- {
- power = 3;
- }
- if (first == "4")
- {
- power = 4;
- }
- if (first == "5")
- {
- power = 5;
- }
- if (first == "6")
- {
- power = 6;
- }
- if (first == "7")
- {
- power = 7;
- }
- if (first == "8")
- {
- power = 8;
- }
- if (first == "9")
- {
- power = 9;
- }
- if (first == "10")
- {
- power = 10;
- }
- if (first == "J")
- {
- power = 11;
- }
- if (first == "Q")
- {
- power = 12;
- }
- if (first == "K")
- {
- power = 13;
- }
- if (first == "A")
- {
- power = 14;
- }
- }
- sum += (type*power);
- }
- if (!players.ContainsKey(item.Key))
- {
- players.Add(item.Key, sum);
- }
- sum = 0;
- }
- foreach (var cardPlayers in players)
- {
- Console.WriteLine($"{cardPlayers.Key}: {cardPlayers.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement