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 Legendary_Fiarming
- {
- class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, int> information = new SortedDictionary<string, int>() { { "shards", 0 }, { "fragments", 0 }, { "motes", 0 } };
- List<string> keyMaterials = new List<string>() { "shards", "fragments", "motes" };
- bool haveWinner = false;
- do
- {
- string input = Console.ReadLine().ToLower();
- string[] splittedInput = input.Split(' ').Where(x=> !string.IsNullOrEmpty(x)).ToArray();
- string[] keys = new string[splittedInput.Length / 2];
- int[] values = new int[splittedInput.Length / 2];
- for (int i = 0, m = 0; i < splittedInput.Length; i += 2, m++)
- {
- values[m] = int.Parse(splittedInput[i]);
- }
- for (int i = 1, m = 0; i < splittedInput.Length; i += 2, m++)
- {
- keys[m] = splittedInput[i];
- }
- for (int i = 0; i < keys.Length; i++)
- {
- if (information.ContainsKey(keys[i]))
- {
- information[keys[i]] += values[i];
- if (information[keyMaterials[0]] >= 250 || information[keyMaterials[1]] >= 250 || information[keyMaterials[2]] >= 250)
- {
- break;
- }
- }
- else
- {
- information[keys[i]] = values[i];
- }
- }
- if (information[keyMaterials[0]] >= 250 || information[keyMaterials[1]] >= 250 || information[keyMaterials[2]] >= 250)
- {
- break;
- }
- } while (!haveWinner);
- string test = information.First(x => x.Value >= 250).ToString();
- if (test.Contains("fragments"))
- {
- Console.WriteLine("Valanyr obtained!");
- test = "fragments";
- information[test] = information[test] - 250;
- }
- else if (test.Contains("shards"))
- {
- Console.WriteLine("Shadowmourne obtained!");
- test = "shards";
- information[test] = information[test] - 250;
- }
- else
- {
- Console.WriteLine("Dragonwrath obtained!");
- test = "motes";
- information[test] = information[test] - 250;
- }
- foreach (var item in information.OrderByDescending(y => y.Value).Where(x => keyMaterials.Contains(x.Key))) //Принтират се тези, които са ключови.
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- foreach (var item in information.OrderBy(y => y.Key).Where(x => !keyMaterials.Contains(x.Key))) //Принтират се останалите, по азбучен ред.
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement