Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Exam834_AnonymusCatche
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, long>> data = new Dictionary<string, Dictionary<string, long>>();
- Dictionary<string, Dictionary<string, long>> catche = new Dictionary<string, Dictionary<string, long>>();
- string line;
- string dataSet = null;
- string dataKey = null;
- long dataSize = 0;
- while((line = Console.ReadLine()) != "thetinggoesskrra")
- {
- string[] tokens = line.Split(new[] { ' ', '-', '>', '|' }, StringSplitOptions.RemoveEmptyEntries);
- if(tokens.Length == 1)
- {
- dataSet = tokens[0];
- if (!data.ContainsKey(dataSet))
- {
- data.Add(dataSet, new Dictionary<string, long>());
- }
- if (catche.ContainsKey(dataSet))
- {
- foreach (var pair in catche[dataSet])
- {
- data[dataSet].Add(pair.Key, pair.Value);
- }
- }
- }
- else if(tokens.Length > 1)
- {
- dataKey = tokens[0];
- dataSize = long.Parse(tokens[1]);
- dataSet = tokens[2];
- if (!data.ContainsKey(dataSet))
- {
- if (!catche.ContainsKey(dataSet))
- {
- catche.Add(dataSet, new Dictionary<string, long>());
- }
- catche[dataSet].Add(dataKey, dataSize);
- }
- else
- {
- data[dataSet].Add(dataKey, dataSize);
- }
- }
- }
- if (data.Count >= 1)
- {
- KeyValuePair<string, Dictionary<string, long>> result = data
- .OrderByDescending(ds => ds.Value.Sum(d => d.Value))
- .First();
- Console.WriteLine($"Data Set: {result.Key}, Total Size: {result.Value.Sum(d => d.Value)}");
- foreach (var value in result.Value)
- {
- //Just printing
- Console.WriteLine($"$.{value.Key}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement