Advertisement
zhivko1985

Untitled

Mar 7th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _5.Hands_of_cards
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. var dict = new Dictionary<string, string>();
  15. while (!input.Equals("end"))
  16. {
  17. var textList = input.Split('=',' ').ToList();
  18. string userName = textList[5];
  19. if (!dict.ContainsKey(userName))
  20. {
  21. dict[userName] = textList[1];
  22. }
  23. else
  24. {
  25. dict[userName] += (" " + string.Join("", textList[1].Take(12)));
  26. }
  27. input = Console.ReadLine();
  28. }
  29. foreach (var item in dict.Keys.OrderBy(x => x))
  30. {
  31. var itemVAlue = dict[item].Split().ToList();
  32. var itemValueDist = dict[item].Split().Distinct().ToList();
  33. string currentText = "";
  34. Console.WriteLine(item + ": ");
  35. foreach (var ip in itemValueDist)
  36. {
  37. int counter = 0;
  38. currentText += ($"{ip} => ");
  39. for (int i = 0; i < itemVAlue.Count; i++)
  40. {
  41. if (itemVAlue[i].Equals(ip))
  42. {
  43. counter++;
  44. }
  45. }
  46. currentText += counter + ", ";
  47. counter = 0;
  48. }
  49. Console.WriteLine(string.Join("", currentText.Take(currentText.Length - 2)) + '.');
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement