Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _07ExerciseLegendaryFarming
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(" ");
- int currentCount = 0;
- var swordDict = new Dictionary<string, int>();
- var junkDict = new SortedDictionary<string, int>();
- bool isTheItemDone = false;
- while (isTheItemDone == false)
- {
- for (int i = 0; i < input.Length; i++)
- {
- if (i % 2 == 0)
- {
- currentCount = int.Parse(input[i]);
- }
- else
- {
- if (input[i].ToLower() == "shards" || input[i].ToLower() == "fragments" || input[i].ToLower() == "motes")
- {
- string item = input[i].ToLower();
- if (!swordDict.ContainsKey(item))
- {
- swordDict[item] = 0;
- }
- swordDict[item] += currentCount;
- if (swordDict[item] >= 250)
- {
- if (item == "shards")
- {
- Console.WriteLine("Shadowmourne obtained!");
- }
- else if (item == "fragments")
- {
- Console.WriteLine("Valanyr obtained!");
- }
- else if (item == "motes")
- {
- Console.WriteLine("Dragonwrath obtained!");
- }
- swordDict[item] -= 250;
- isTheItemDone = true;
- break;
- }
- }
- else
- {
- string item = input[i].ToLower();
- if (!junkDict.ContainsKey(item))
- {
- junkDict[item] = 0;
- }
- junkDict[item] += currentCount;
- }
- }
- }
- if (isTheItemDone==true)
- {
- break;
- }
- input = Console.ReadLine().Split(" ");
- }
- Dictionary<string, int> sortedDict = swordDict.OrderByDescending(x => x.Value)
- .ThenBy(x => x.Key)
- .ToDictionary(x => x.Key,
- x => x.Value);
- foreach (var item in sortedDict)
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- foreach (var item in junkDict)
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement