Advertisement
Guest User

Untitled

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