Program.cs 560 B

12345678910111213141516171819
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. namespace D07._1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. if (args.Length < 1) throw new ArgumentException();
  11. if (File.Exists(args[0]) == false) throw new FileNotFoundException();
  12. var r = new Regex(@"(?!^.*\[\w*(\w)(?!\1)(\w)\2\1\w*\])^.*(\w)(?!\3)(\w)\4\3", RegexOptions.Multiline)
  13. .Matches(File.ReadAllText(args[0]));
  14. Console.WriteLine($"The answer is : {r.Count}");
  15. }
  16. }
  17. }