private bool IsValid2(PasswordInfo pi) { var foundAtMinPosition = pi.Password[pi.PasswordPolicy.Min - 1] == pi.PasswordPolicy.Letter; var foundAtMaxPosition = pi.Password[pi.PasswordPolicy.Max - 1] == pi.PasswordPolicy.Letter; return(foundAtMinPosition ^ foundAtMaxPosition); }
private bool IsValid1(PasswordInfo pi) { var letterCount = pi.Password.Count(c => c == pi.PasswordPolicy.Letter); return(letterCount >= pi.PasswordPolicy.Min && letterCount <= pi.PasswordPolicy.Max); }
private static bool IsValidPart2(PasswordInfo passwordInfo) { return((passwordInfo.Password[passwordInfo.Min - 1] == passwordInfo.Letter) ^ passwordInfo.Password[passwordInfo.Max - 1] == passwordInfo.Letter); }
private static bool IsValidPart1(PasswordInfo passwordInfo) { int count = passwordInfo.Password.Count(c => c == passwordInfo.Letter); return(count >= passwordInfo.Min && count <= passwordInfo.Max); }