Advertisement
Guest User

Untitled

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