Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LegendaryFearming
- {
- class Program
- {
- static void Main(string[] args)
- {
- var template = 0;
- var materialsCollection = new Dictionary<string, long>();
- materialsCollection["shards"] = 0;
- materialsCollection["fragments"] = 0;
- materialsCollection["motes"] = 0;
- string legendaryItem = "";
- var input = String.Empty;
- bool breakPoint = true;
- while (breakPoint)
- {
- input = Console.ReadLine();
- var items = input.ToLower().Split();
- long quantity = 0;
- string material = "";
- for (int index = 1; index <= items.Length; index += 2)
- {
- material = items[index];
- quantity = long.Parse(items[index - 1]);
- if (!materialsCollection.ContainsKey(material))
- {
- materialsCollection[material] = 0;
- }
- materialsCollection[material] += quantity;
- if (materialsCollection[material] >= 250 && (material == "fragments" || material =="shards"
- || material == "motes"))
- {
- materialsCollection[material] -= 250;
- legendaryItem = material;
- breakPoint = false;
- break;
- }
- }
- }
- if (legendaryItem == "shards")
- {
- Console.WriteLine("Shadowmourne obtained!");
- }
- else if (legendaryItem == "fragments")
- {
- Console.WriteLine("Valanyr obtained!");
- }
- else if (legendaryItem == "motes")
- {
- Console.WriteLine("Dragonwrath obtained!");
- }
- var sortedKeyItems = materialsCollection.Take(3).OrderByDescending(x => x.Value).ThenBy(x => x.Key);
- var sortedJunksItems = materialsCollection.Skip(3).OrderBy(a => a.Key);
- foreach (var sortedKeyMaterial in sortedKeyItems)
- {
- var item = sortedKeyMaterial.Key;
- var value = sortedKeyMaterial.Value;
- Console.WriteLine($"{item}: {value}");
- }
- foreach (var sortedJunkMaterial in sortedJunksItems)
- {
- Console.WriteLine($"{sortedJunkMaterial.Key}: {sortedJunkMaterial.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement