sivancheva

LegendaryFarming2

Oct 16th, 2017
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace _21_09_LegendaryFarming
  7. {
  8. class LegendaryFarming
  9. {
  10. static void Main(string[] args)
  11. {
  12.  
  13. var input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim().ToLower()).ToArray();
  14.  
  15. bool finished = false;
  16.  
  17. var keyMaterial = new Dictionary<string, int>();
  18. var junkMaterial = new Dictionary<string, int>();
  19.  
  20. keyMaterial.Add("fragments", 0);
  21. keyMaterial.Add("shards", 0);
  22. keyMaterial.Add("motes", 0);
  23.  
  24. int counterLines = 1;
  25. while (counterLines != 10)
  26. {
  27.  
  28. for (int i = 0; i < input.Length; i += 2)
  29. {
  30. int quantity = int.Parse(input[i]);
  31. var material = input[i + 1];
  32.  
  33. if (material == "fragments" || material == "shards" || material == "motes")
  34. {
  35.  
  36. keyMaterial[material] += quantity;
  37.  
  38. if (keyMaterial[material] >= 250 )
  39. {
  40.  
  41. if (material == "fragments")
  42. {
  43. Console.WriteLine("Valanyr obtained!");
  44. }
  45. else if (material == "shards")
  46. {
  47. Console.WriteLine("Shadowmourne obtained!");
  48. }
  49. else
  50. {
  51. Console.WriteLine("Dragonwrath obtained!");
  52. }
  53.  
  54. keyMaterial[material] = keyMaterial[material] - 250;
  55.  
  56. finished = true;
  57. if (finished)
  58. {
  59. break;
  60. }
  61.  
  62. }
  63. }
  64. else
  65. {
  66. if (!junkMaterial.ContainsKey(material))
  67. {
  68. junkMaterial.Add(material, quantity);
  69. }
  70. else
  71. {
  72. junkMaterial[material] += quantity;
  73. }
  74.  
  75. }
  76.  
  77. }
  78. counterLines++;
  79. if (finished)
  80. {
  81. break;
  82. }
  83.  
  84. input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim().ToLower()).ToArray();
  85. }
  86.  
  87.  
  88.  
  89. foreach (var item in keyMaterial.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  90. {
  91. Console.WriteLine($"{item.Key}: {item.Value}");
  92.  
  93. }
  94. foreach (var item in junkMaterial.OrderBy(x => x.Key))
  95. {
  96. Console.WriteLine($"{item.Key}: {item.Value}");
  97. }
  98.  
  99. ;
  100.  
  101. }
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment