Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _05.Hands_of_Cards
- {
- class Program
- {
- static void Main()
- {
- char[] delimiters = new char[] { ',', ':', ' ' };
- string[] input = Console.ReadLine().Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
- Dictionary<string, List<string>> players = new Dictionary<string, List<string>>();
- string[] powers = new string[] { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" };
- string[] types = new string[] { "C", "D", "H", "S" };
- while (input[0] != "JOKER")
- {
- List<string> cards = new List<string>();
- for (int i = 1; i < input.Length; i++)
- {
- cards.Add(input[i]);
- }
- if (!players.ContainsKey(input[0]))
- {
- players.Add(input[0], cards);
- }
- else
- {
- players[input[0]].AddRange(cards);
- }
- input = Console.ReadLine().Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
- }
- foreach (var list in players)
- {
- int currPoints = 0;
- List<string> currentList = list.Value.Distinct().ToList();
- foreach (var item in currentList)
- {
- if (Array.IndexOf(powers, item.Remove(item.Length - 1)) != -1 && Array.IndexOf(types, item[item.Length-1].ToString()) != -1)
- {
- currPoints += (Array.IndexOf(powers, item.Remove(item.Length - 1)) + 2) * (Array.IndexOf(types, item[item.Length - 1].ToString()) + 1);
- }
- }
- Console.WriteLine($"{list.Key}: {currPoints}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement