sivancheva

LegendaryFarming

Oct 16th, 2017
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 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. var keyMaterial = new Dictionary<string, int>();
  16. var junkMaterial = new Dictionary<string, int>();
  17.  
  18. keyMaterial.Add("fragments", 0);
  19. keyMaterial.Add("shards", 0);
  20. keyMaterial.Add("motes", 0);
  21.  
  22. int counterLines = 1;
  23. while (counterLines != 10)
  24. {
  25.  
  26. for (int i = 0; i < input.Length; i += 2)
  27. {
  28. int quantity = int.Parse(input[i]);
  29. var material = input[i + 1];
  30.  
  31. if (material == "fragments" || material == "shards" || material == "motes")
  32. {
  33.  
  34. keyMaterial[material] += quantity;
  35.  
  36. if (keyMaterial[material] >= 250)
  37. {
  38.  
  39. if (material == "fragments")
  40. {
  41. Console.WriteLine("Valanyr obtained!");
  42. }
  43. else if (material == "shards")
  44. {
  45. Console.WriteLine("Shadowmourne obtained!");
  46. }
  47. else
  48. {
  49. Console.WriteLine("Dragonwrath obtained!");
  50. }
  51.  
  52. keyMaterial[material] = keyMaterial[material] - 250;
  53. goto End;
  54. }
  55. }
  56. else
  57. {
  58. if (!junkMaterial.ContainsKey(material))
  59. {
  60. junkMaterial.Add(material, quantity);
  61. }
  62. else
  63. {
  64. junkMaterial[material] += quantity;
  65. }
  66.  
  67. }
  68.  
  69. }
  70. counterLines++;
  71. input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim().ToLower()).ToArray();
  72. }
  73.  
  74. End:
  75.  
  76. foreach (var item in keyMaterial.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  77. {
  78. Console.WriteLine($"{item.Key}: {item.Value}");
  79.  
  80. }
  81. foreach (var item in junkMaterial.OrderBy(x => x.Key))
  82. {
  83. Console.WriteLine($"{item.Key}: {item.Value}");
  84. }
  85.  
  86. ;
  87.  
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment