Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace _05.Hand_of_Cards_v3
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Dictionary<string, List<string>> playerHands = new Dictionary<string, List<string>>();
  12. while (true)
  13. {
  14. List<string> line = Console.ReadLine().Split(',',' ',StringSplitOptions.RemoveEmptyEntries).ToList();
  15. string player = line[0];
  16. List<string> hands = new List<string>();
  17. if (player == "JOKER")
  18. {
  19. break;
  20. }
  21. if (!playerHands.ContainsKey(player))
  22. {
  23. playerHands.Add(player, hands);
  24. }
  25. playerHands[player] = line.Skip(1).Distinct().Concat(playerHands[player]).Distinct().ToList();
  26. }
  27. foreach (var item in playerHands)
  28. {
  29. Console.WriteLine($"{item.Key} {String.Join(" ",item.Value)}");
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement