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.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- var users = Console.ReadLine().Split(new[] {' ', ')' , '(' , '/' , '\\' }, StringSplitOptions.RemoveEmptyEntries);
- var pattern = @"[^() /\\0-9][^()/\\ ]{1,23}[^()/\\ ]";
- Regex r = new Regex(pattern);
- var validUsers = new List<string>();
- foreach (var item in users)
- {
- var match = r.Match(item);
- if (match.Length == item.Length)
- {
- validUsers.Add(item);
- // Console.WriteLine(item.ToString());
- }
- }
- int fIndex=1;
- int sIndex=1;
- int maxSum = 0;
- for (int i = 1; i < validUsers.Count ; i++)
- {
- if((validUsers[i-1].Length + validUsers[i].Length) > maxSum)
- {
- fIndex = i - 1;
- sIndex = i;
- maxSum = validUsers[i - 1].Length + validUsers[i].Length;
- }
- }
- Console.WriteLine(validUsers[fIndex]);
- Console.WriteLine(validUsers[sIndex]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement