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;
- using System.Threading.Tasks;
- namespace ValidUsernames
- {
- class ValidUsernames // Alexander Anguelov
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string userName = @"\b\w{3,25}\b";
- MatchCollection matches = Regex.Matches(input, userName);
- List<string> valid = new List<string>();
- foreach (var match in matches)
- {
- if (char.IsLetter(match.ToString().First()))
- {
- valid.Add(match.ToString());
- }
- }
- int biggestSum = 0;
- int pos = 0;
- for (int i = 0; i < valid.Count - 1; i++)
- {
- int currSum = valid[i].Length + valid[i + 1].Length;
- if (currSum > biggestSum)
- {
- biggestSum = currSum;
- pos = i;
- }
- }
- Console.WriteLine(valid[pos]);
- Console.WriteLine(valid[pos + 1]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement