Zarodath

Untitled

Dec 9th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 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 RE_Anon_Cache
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. //List and dict
  14. var _ListOfSets = new List<string>();
  15. var _DictOFData = new Dictionary<string, Dictionary<string, long>>();
  16.  
  17.  
  18. string input = Console.ReadLine();
  19.  
  20. while (input != "thetinggoesskrra")
  21. {
  22. if (input.Contains(" -> "))
  23. {
  24. string[] commands = input.Split(" ->|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToArray();
  25. string Data_Key = commands[0];
  26. long Data_Size = long.Parse(commands[1]);
  27. string Data_Set = commands[2];
  28.  
  29. if (!_DictOFData.ContainsKey(Data_Set))
  30. {
  31. _DictOFData[Data_Set] = new Dictionary<string, long>();
  32. }
  33. _DictOFData[Data_Set][Data_Key] = Data_Size;
  34. }
  35. else
  36. {
  37. _ListOfSets.Add(input);
  38. }
  39. input = Console.ReadLine();
  40. }
  41.  
  42. //Output
  43. foreach (var item in _ListOfSets)
  44. {
  45. if (!_DictOFData.ContainsKey(item))
  46. {
  47. _DictOFData.Remove(item);
  48. }
  49. }
  50.  
  51. if (_DictOFData.Count > 0)
  52. {
  53. var result = _DictOFData.OrderByDescending(x => x.Value.Sum(e => e.Value)).First();
  54. Console.WriteLine($"Data Set: {result.Key}, Total Size: {result.Value.Sum(x => x.Value)}");
  55. foreach (var item in result.Value)
  56. {
  57. Console.WriteLine($"$.{item.Key}");
  58. }
  59. }
  60. }
  61. }
  62. }
Add Comment
Please, Sign In to add comment