Guest User

Untitled

a guest
Oct 15th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class LegendaryFarming
  6. {
  7.     static void Main()
  8.     {
  9.         Dictionary<string, long> keyMaterials = new Dictionary<string, long>();
  10.         keyMaterials["shards"] = 0;
  11.         keyMaterials["motes"] = 0;
  12.         keyMaterials["fragments"] = 0;
  13.  
  14.         SortedDictionary<string, long> junkMaterials = new SortedDictionary<string, long>();
  15.         bool isInput = true;
  16.  
  17.         while (isInput)
  18.         {
  19.             string[] materials = Console.ReadLine().ToLower().Split(' ').ToArray();
  20.             for (int i = 0; i < materials.Length; i++)
  21.             {
  22.                 long curentQuantiti = long.Parse(materials[i]);
  23.                 string curentMaterial = materials[i + 1];
  24.                 if (curentMaterial == "shards" || curentMaterial == "motes" || curentMaterial == "fragments")
  25.                 {
  26.                     keyMaterials[curentMaterial] += curentQuantiti;
  27.                 }
  28.                 else
  29.                 {
  30.                     if (!junkMaterials.ContainsKey(curentMaterial))
  31.                     {
  32.                         junkMaterials.Add(curentMaterial, 0);
  33.                     }
  34.                     junkMaterials[curentMaterial] += curentQuantiti;
  35.                 }
  36.                 i += 1;
  37.                 if (keyMaterials["shards"] >= 250 || keyMaterials["motes"] >= 250 || keyMaterials["fragments"] >= 250)
  38.                 {
  39.                     foreach (var item in keyMaterials.OrderByDescending(x => x.Value))
  40.                     {
  41.                         switch (item.Key)
  42.                         {
  43.                             case "motes":
  44.                                 Console.WriteLine("Dragonwrath obtained!");
  45.                                 keyMaterials[item.Key] -= 250;
  46.                                 break;
  47.                             case "shards":
  48.                                 Console.WriteLine("Shadowmourne obtained!");
  49.                                 keyMaterials[item.Key] -= 250;
  50.                                 break;
  51.                             case "fragments":
  52.                                 Console.WriteLine("Valanyr obtained!");
  53.                                 keyMaterials[item.Key] -= 250;
  54.                                 break;
  55.                         }
  56.                         break;
  57.                     }
  58.                     foreach (var item in keyMaterials.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  59.                     {
  60.                         Console.WriteLine("{0}: {1}", item.Key, item.Value);
  61.                     }
  62.                     foreach (var item in junkMaterials)
  63.                     {
  64.                         Console.WriteLine("{0}: {1}", item.Key, item.Value);
  65.                     }
  66.                     isInput = false;
  67.                 }
  68.             }
  69.         }
  70.     }
  71. }
Add Comment
Please, Sign In to add comment