Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- class Program
- {
- public static Regex singleMethodInitialization = new Regex(@"(?<=static)\s+.*?\s+([A-Za-z][A-Za-z0-9]+)(.*?)(static|$)");
- public static Regex singleMethodCall = new Regex("([a-zA-Z]*[A-Z]{1}[a-zA-Z]*)\\s*\\(");
- public static Dictionary<string, List<string>> storage = new Dictionary<string, List<string>>();
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- stringBuilder.Append(input);
- }
- string text = stringBuilder.ToString();
- if (!singleMethodInitialization.IsMatch(text))
- {
- return;
- }
- var matches = singleMethodInitialization.Matches(text);
- foreach (Match method in matches)
- {
- string parentPethod = method.Groups[1].ToString();
- if (!storage.ContainsKey(parentPethod))
- {
- storage[parentPethod] = new List<string>();
- }
- string methodBody = method.Groups[2].ToString();
- foreach (Match methodCall in singleMethodCall.Matches(methodBody))
- {
- storage[parentPethod].Add(methodCall.Groups[1].ToString());
- }
- }
- Print();
- }
- public static void Print()
- {
- foreach (var parentPethod in storage.OrderBy(x => -x.Value.Count).ThenBy(x => x.Key))
- {
- var methodCalls = parentPethod.Value.OrderBy(x => x).ToList();
- if (methodCalls.Count == 0)
- {
- Console.WriteLine($"{parentPethod.Key} -> None");
- }
- else
- {
- Console.WriteLine($"{parentPethod.Key} -> {parentPethod.Value.Count} -> {string.Join(", ", methodCalls)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement