Advertisement
Guest User

04. Files.Broken 60/100

a guest
May 11th, 2017
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. namespace SendNudes
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Linq;
  6.     using System.Numerics;
  7.     using System.Text.RegularExpressions;
  8.  
  9.     class StringsDemoBro
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             var listed = new List<string>();
  16.             var results = new Dictionary<string, ulong>();
  17.  
  18.             for (int i = 0; i < n; i++)
  19.             {
  20.                 var input = Console.ReadLine();
  21.                 listed.Add(input);
  22.             }
  23.  
  24.             var extRoot = Console.ReadLine().Split();
  25.  
  26.             for (int i = 0; i < listed.Count; i++)
  27.             {
  28.                 if (listed[i].Contains(extRoot[0]) && listed[i].Contains(extRoot[2]))
  29.                 {
  30.                     var currentWord = listed[i].Split(new char[] { ' ', '\\', ';' }, StringSplitOptions.RemoveEmptyEntries);
  31.  
  32.                     var size = ulong.Parse(currentWord[currentWord.Length - 1]);
  33.                     var fileNameExt = currentWord[currentWord.Length - 2];
  34.  
  35.                     var fileName = fileNameExt;
  36.  
  37.                     if (!results.ContainsKey(fileNameExt))
  38.                     {
  39.                         results.Add(fileNameExt, size);
  40.                     }
  41.                     else
  42.                     {
  43.                         results[fileNameExt] = size;
  44.                     }
  45.                 }
  46.             }
  47.  
  48.             if (results.Count == 0)
  49.             {
  50.                 Console.WriteLine("No");
  51.                 return;
  52.             }
  53.  
  54.             foreach (var result in results.OrderByDescending(x => x.Value).ThenBy(k => k.Key))
  55.             {
  56.                 Console.WriteLine($"{result.Key} - {result.Value} KB ");
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement