Advertisement
Guest User

Legendary Item

a guest
Mar 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.00 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.             List<string> Input = Console.ReadLine().Split(" ").Select(x=>x.ToLower()).ToList();
  12.             Dictionary <string, int> LegendaryItem = new Dictionary<string, int>();
  13.             SortedDictionary<string, string> MaterialItem = new SortedDictionary<string, string>();
  14.             MaterialItem.Add("shards", "Shadowmourne");
  15.             MaterialItem.Add("fragments", "Valanyr");
  16.             MaterialItem.Add("motes", "Dragonwrath");  
  17.             Dictionary<string, int> Crap = new Dictionary<string, int>();
  18.             int count = 1;
  19.             LegendaryItem.Add("shards", 0);
  20.             LegendaryItem.Add("fragments", 0);
  21.             LegendaryItem.Add("motes", 0);
  22.             bool isWinner = false;
  23.             string winner = String.Empty;
  24.  
  25.             while (count <= Input.Count && !isWinner)
  26.             {
  27.                 if (count % 2 != 0)
  28.                 {
  29.                     //quantity
  30.                     if (LegendaryItem.ContainsKey(Input[count]))
  31.                     {
  32.                         LegendaryItem[Input[count]] += int.Parse(Input[count - 1]);
  33.                     }
  34.                     else
  35.                     {
  36.                         if (Crap.ContainsKey(Input[count]))
  37.                         {
  38.                             Crap[Input[count]] += int.Parse(Input[count - 1]);
  39.                         }
  40.                         else
  41.                         {
  42.                             Crap.Add(Input[count], int.Parse(Input[count - 1]));
  43.                         }
  44.                     }
  45.  
  46.                 }
  47.                 for (int i = 0; i < LegendaryItem.Count; i++)
  48.                 {
  49.                     if (LegendaryItem.ElementAt(i).Value >= 250)
  50.                     {
  51.                         int tempValue = LegendaryItem.ElementAt(i).Value - 250;
  52.                         string tempKey = LegendaryItem.ElementAt(i).Key;
  53.                         winner = LegendaryItem.ElementAt(i).Key;
  54.                         LegendaryItem[tempKey] = tempValue;
  55.                         isWinner = true;
  56.                         break;                      
  57.                     }
  58.                 }
  59.                 count++;
  60.             }
  61.  
  62.  
  63.  
  64.  
  65.             LegendaryItem=LegendaryItem.OrderByDescending(x => x.Value).ThenBy(x => x.Key).ToDictionary(x=>x.Key, x=>x.Value);
  66.             Crap = Crap.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
  67.  
  68.            if (isWinner)
  69.            {
  70.                 Console.WriteLine($"{MaterialItem[winner]} obtained!");
  71.                
  72.             }
  73.  
  74.             foreach (var item in LegendaryItem)
  75.             {
  76.                 Console.WriteLine($"{item.Key}: {item.Value}");
  77.             }
  78.  
  79.             foreach (var item in Crap)
  80.             {
  81.                 Console.WriteLine($"{item.Key}: {item.Value}");
  82.             }
  83.  
  84.  
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement