Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03._LegendaryFarming
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> materials = new Dictionary<string, int>();
- materials.Add("motes", 0);
- materials.Add("shards", 0);
- materials.Add("fragments", 0);
- while (materials["motes"] < 250 &&
- materials["fragments"] < 250 &&
- materials["shards"] < 250)
- {
- List<string> list = Console.ReadLine().ToLower().Split(" ").ToList();
- string key = string.Empty;
- int value = 0;
- for (int i = 0; i < list.Count; i++)
- {
- if (materials["motes"] >= 250 ||
- materials["fragments"] >= 250 ||
- materials["shards"] >= 250) break;
- if (i % 2 == 0)
- {
- value = int.Parse(list[i]);
- }
- else
- {
- key = list[i];
- }
- if (key != string.Empty && value != 0)
- {
- if (!materials.ContainsKey(key))
- {
- materials.Add(key, value);
- }
- else
- {
- materials[key] += value;
- }
- key = string.Empty; value = 0;
- }
- }
- }
- if (materials["motes"] >= 250)
- {
- Console.WriteLine("Dragonwrath obtained!");
- materials["motes"] -= 250;
- }
- else if (materials["fragments"] >= 250)
- {
- Console.WriteLine("Valanyr obtained!");
- materials["fragments"] -= 250;
- }
- else if (materials["shards"] >= 250)
- {
- Console.WriteLine("Shadowmourne obtained!");
- materials["shards"] -= 250;
- }
- Dictionary<string, int> keyMaterials = new Dictionary<string, int>();
- keyMaterials.Add("motes", materials["motes"]);
- keyMaterials.Add("fragments", materials["fragments"]);
- keyMaterials.Add("shards", materials["shards"]);
- foreach (var item in keyMaterials.OrderByDescending(key => key.Value).ThenBy(key => key.Key))
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- Dictionary<string, int> junk = materials;
- junk.Remove("motes");
- junk.Remove("shards");
- junk.Remove("fragments");
- foreach (var item in junk.OrderBy(key => key.Key))
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement