Beispiel #1
0
        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);
        }
Beispiel #2
0
        private bool IsValid1(PasswordInfo pi)
        {
            var letterCount = pi.Password.Count(c => c == pi.PasswordPolicy.Letter);

            return(letterCount >= pi.PasswordPolicy.Min &&
                   letterCount <= pi.PasswordPolicy.Max);
        }
Beispiel #3
0
 private static bool IsValidPart2(PasswordInfo passwordInfo)
 {
     return((passwordInfo.Password[passwordInfo.Min - 1] == passwordInfo.Letter) ^ passwordInfo.Password[passwordInfo.Max - 1] == passwordInfo.Letter);
 }
Beispiel #4
0
        private static bool IsValidPart1(PasswordInfo passwordInfo)
        {
            int count = passwordInfo.Password.Count(c => c == passwordInfo.Letter);

            return(count >= passwordInfo.Min && count <= passwordInfo.Max);
        }