private static bool ValidatePasswordPart1(CorruptedPassword pCorruptedPassword) { int characterCount = pCorruptedPassword.Password.Count( pCharacter => pCharacter == pCorruptedPassword.Character); return(characterCount >= pCorruptedPassword.Min && characterCount <= pCorruptedPassword.Max); }
private static bool ValidatePasswordPart2(CorruptedPassword pCorruptedPassword) { char char1 = SafelyGetChar(pCorruptedPassword.Password, pCorruptedPassword.Min); char char2 = SafelyGetChar(pCorruptedPassword.Password, pCorruptedPassword.Max); bool isValid = char1 == pCorruptedPassword.Character ^ char2 == pCorruptedPassword.Character; Console.WriteLine($"{isValid} - {pCorruptedPassword}, 1={char1}, 2={char2}"); return(isValid); }