Advertisement
Guest User

Untitled

a guest
Jul 18th, 2021
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace LegendaryFarming
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Dictionary<string, int> dictionary = new Dictionary<string, int>();
  12.  
  13.             dictionary.Add("motes", 0);
  14.             dictionary.Add("fragments", 0);
  15.             dictionary.Add("shards", 0);
  16.  
  17.             bool isFound = false;
  18.             int counter = 0;
  19.             int quantity = 0;
  20.  
  21.             while (!isFound)
  22.             {
  23.                 string[] materials = Console.ReadLine().ToLower().Split();
  24.  
  25.                 for (int i = 0; i < materials.Length; i++)
  26.                 {
  27.                     counter++;
  28.                     if (counter % 2 != 0)
  29.                     {
  30.                         quantity = int.Parse(materials[i]);
  31.                     }
  32.                     else
  33.                     {
  34.                         if (!dictionary.ContainsKey(materials[i]))
  35.                         {
  36.                             dictionary.Add(materials[i], 0);
  37.                         }
  38.                         dictionary[materials[i]] += quantity;
  39.                     }
  40.  
  41.                     if (dictionary["shards"] >= 250 || dictionary["fragments"] >= 250 || dictionary["motes"] >= 250)
  42.                     {
  43.                         if (materials[i] == "motes")
  44.                         {
  45.                             Console.WriteLine("Dragonwrath obtained!");
  46.                         }
  47.                         else if (materials[i] == "fragments")
  48.                         {
  49.                             Console.WriteLine("Valanyr obtained!");
  50.                         }
  51.                         else if (materials[i] == "shards")
  52.                         {
  53.                             Console.WriteLine("Shadowmourne obtained!");
  54.                         }
  55.  
  56.                         dictionary[materials[i]] = dictionary[materials[i]] - 250;
  57.                         isFound = true;
  58.                         break;
  59.                     }
  60.                 }
  61.             }
  62.  
  63.             foreach (var item in dictionary.OrderByDescending(key => key.Value).ThenBy(key => key.Key))
  64.             {
  65.                 if (item.Key == "motes" || item.Key == "fragments" || item.Key == "shards")
  66.                 {
  67.                     Console.WriteLine($"{item.Key}: {item.Value}");
  68.                 }
  69.             }
  70.             foreach (var item in dictionary.OrderBy(x => x.Key))
  71.             {
  72.                 if (item.Key != "motes" && item.Key != "fragments" && item.Key != "shards")
  73.                 {
  74.                     Console.WriteLine($"{item.Key}: {item.Value}");
  75.                 }
  76.             }
  77.  
  78.  
  79.         }
  80.     }
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement