Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace JediDreams
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- public class StartUp
- {
- public static void Main()
- {
- Regex methodDeclaretion = new Regex(@"static\s+.*?\s+([a-zA-Z]*[A-Z]{1}[a-zA-Z]*)\s*\(");
- Regex methodInvoke = new Regex(@"([a-zA-Z]*[A-Z]{1}[a-zA-Z]*)\s*\(");
- Dictionary<string, List<string>> methodCalls = new Dictionary<string, List<string>>();
- string lastMethodDeclared = default(string);
- int countOfInputLines = int.Parse(Console.ReadLine());
- for (int currentInputLine = 0; currentInputLine < countOfInputLines; currentInputLine++)
- {
- string inputLine = Console.ReadLine();
- Match match = methodDeclaretion.Match(inputLine);
- MatchCollection allMatches = methodInvoke.Matches(inputLine);
- if (match.Success)
- {
- lastMethodDeclared = match.Groups[1].Value;
- if (!methodCalls.ContainsKey(lastMethodDeclared))
- {
- methodCalls[lastMethodDeclared] = new List<string>();
- }
- }
- else if (allMatches.Count != 0 && lastMethodDeclared != default(string))
- {
- foreach (Match currMatch in allMatches)
- {
- methodCalls[lastMethodDeclared].Add(currMatch.Groups[1].Value);
- }
- }
- }
- StringBuilder result = new StringBuilder();
- foreach (KeyValuePair<string, List<string>> kvp in methodCalls.OrderByDescending(mc => mc.Value.Count).ThenBy(n => n.Key))
- {
- result.Append($"{kvp.Key} -> ");
- if (kvp.Value.Count == 0)
- {
- result.AppendLine("None");
- }
- else
- {
- result.Append($"{kvp.Value.Count} -> ").AppendLine(string.Join(", ", kvp.Value.OrderBy(s => s)));
- }
- }
- Console.Write(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement