Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.09 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4. using System.Collections.Generic;
  5. using System.Runtime.CompilerServices;
  6.  
  7. namespace AnonymousCache
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Dictionary<string, Dictionary<string, long>> dataSets = new Dictionary<string, Dictionary<string, long>>();
  14.             Dictionary<string, Dictionary<string, long>> cached = new Dictionary<string, Dictionary<string, long>>();
  15.  
  16.             BigInteger total = 0;
  17.  
  18.             while (true)
  19.             {
  20.                 string input = Console.ReadLine();
  21.                 if (input == String.Empty)
  22.                 {
  23.                     continue;
  24.                 }
  25.  
  26.                 if (input == "thetinggoesskrra")
  27.                 {
  28.                     foreach (var set in dataSets)
  29.                     {
  30.                         foreach (var cset in cached)
  31.                         {
  32.                             foreach (var c in cset.Value)
  33.                             {
  34.                                 if (set.Key == cset.Key)
  35.                                 {
  36.                                     dataSets[set.Key].Add(c.Key, c.Value);
  37.                                 }
  38.                             }
  39.                         }
  40.                     }
  41.  
  42.  
  43.                     foreach (var s in dataSets.OrderByDescending(x => x.Value.Values.Sum()))
  44.                     {
  45.                         foreach (var q in s.Value)
  46.                         {
  47.                             total += q.Value;
  48.                         }
  49.  
  50.                         Console.WriteLine($"Data Set: {s.Key}, Total Size: {total}");
  51.                         foreach (var z in s.Value)
  52.                         {
  53.                             Console.WriteLine($"$.{z.Key}");
  54.                         }
  55.  
  56.                         break;
  57.                     }
  58.  
  59.                     break;
  60.                 }
  61.  
  62.                 string[] token = input
  63.                     .Split(new char[] {' ', '-', ';', '>', '|'}, StringSplitOptions.RemoveEmptyEntries)
  64.                     .ToArray();
  65.                 if (token.Length > 1)
  66.                 {
  67.                     string dataKey = token[0];
  68.                     long dataSize = long.Parse(token[1]);
  69.                     string dataSet = token[2];
  70.  
  71.                     if (!cached.ContainsKey(dataSet))
  72.                     {
  73.                         cached.Add(dataSet, new Dictionary<string, long>());
  74.                         cached[dataSet].Add(dataKey, dataSize);
  75.                     }
  76.                     else
  77.                     {
  78.                         if (!cached[dataSet].ContainsKey(dataKey))
  79.                         {
  80.                             cached[dataSet].Add(dataKey, dataSize);
  81.                         }
  82.                     }
  83.                 }
  84.                 else
  85.                 {
  86.                     if (!dataSets.ContainsKey(token[0]))
  87.                     {
  88.                         dataSets.Add(token[0], new Dictionary<string, long>());
  89.                     }
  90.                 }
  91.             }
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement