Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. var users = Console.ReadLine().Split(new[] {' ', ')' , '(' , '/' , '\\' }, StringSplitOptions.RemoveEmptyEntries);
  15. var pattern = @"[^() /\\0-9][^()/\\ ]{1,23}[^()/\\ ]";
  16. Regex r = new Regex(pattern);
  17. var validUsers = new List<string>();
  18. foreach (var item in users)
  19. {
  20. var match = r.Match(item);
  21. if (match.Length == item.Length)
  22. {
  23. validUsers.Add(item);
  24. // Console.WriteLine(item.ToString());
  25. }
  26. }
  27. int fIndex=1;
  28. int sIndex=1;
  29. int maxSum = 0;
  30. for (int i = 1; i < validUsers.Count ; i++)
  31. {
  32. if((validUsers[i-1].Length + validUsers[i].Length) > maxSum)
  33. {
  34. fIndex = i - 1;
  35. sIndex = i;
  36. maxSum = validUsers[i - 1].Length + validUsers[i].Length;
  37. }
  38. }
  39. Console.WriteLine(validUsers[fIndex]);
  40. Console.WriteLine(validUsers[sIndex]);
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement