damyan91

Untitled

Feb 4th, 2017
289
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _09.Legendary_Farming
  8. {
  9. public class LegendaryFarming
  10. {
  11. static void Main()
  12. {
  13. string input = Console.ReadLine();
  14. bool sum = true;
  15. var materialsInfo = new Dictionary<string, int>();
  16. materialsInfo["shards"] = 0;
  17. materialsInfo["fragments"] = 0;
  18. materialsInfo["motes"] = 0;
  19. string winner = string.Empty;
  20.  
  21. while (sum)
  22. {
  23. string[] items = input.ToLower().Split(' ');
  24. int quantity = 0;
  25. string material = string.Empty;
  26.  
  27. for (int i = 1; i <= items.Length; i += 2)
  28. {
  29. material = items[i].ToLower();
  30.  
  31. quantity = int.Parse(items[i - 1]);
  32.  
  33. if (!materialsInfo.ContainsKey(material))
  34. {
  35. materialsInfo.Add(material, 0);
  36. }
  37.  
  38. materialsInfo[material] += quantity;
  39.  
  40. if (materialsInfo[material] >= 250)
  41. {
  42. winner = material;
  43. materialsInfo[material] -= 250;
  44. sum = false;
  45. break;
  46. }
  47. }
  48. input = Console.ReadLine();
  49. }
  50.  
  51. if (winner == "shards")
  52. {
  53. Console.WriteLine("Shadowmourne obtained!");
  54. }
  55. else if (winner == "fragments")
  56. {
  57. Console.WriteLine("Valanyr obtained!");
  58. }
  59. else if (winner == "motes")
  60. {
  61. Console.WriteLine("Dragonwrath obtained!");
  62. }
  63.  
  64. var sortedKeyMaterials = materialsInfo.Take(3).OrderByDescending(x => x.Value).ThenBy(x => x.Key);
  65. var sortedJunk = materialsInfo.Skip(3).OrderBy(x => x.Key);
  66.  
  67. foreach (var item in sortedKeyMaterials)
  68. {
  69. Console.WriteLine($"{item.Key}: {item.Value}");
  70. }
  71.  
  72. foreach (var item in sortedJunk)
  73. {
  74. Console.WriteLine($"{item.Key}: {item.Value}");
  75. }
  76. }
  77. }
  78. }
RAW Paste Data