using System.Collections.Generic;
public static void Main()
string tx = string.Format("{0} {1}", null, null);
string userfirstname = "mohammed";
string userlastname = "rizwan";
string userfullname = string.Concat(userfirstname, userlastname);
string password = "rizwan";
if (IsPasswordValid(password,userfullname)){
Console.WriteLine("good to go");
Console.WriteLine("Should not contain 3 consec characters");
public static bool IsPasswordValid(string newPassword, string userfullName)
List<string> substrings = new List<string>();
for (int i = 0; i < userfullName.Length-2; i++)
substrings.Add(userfullName.Substring(i, 3));
return !substrings.Any(s => newPassword.Contains(s));