Example #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);
        }
Example #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);
        }
Example #3
0
 private static bool IsValidPart2(PasswordInfo passwordInfo)
 {
     return((passwordInfo.Password[passwordInfo.Min - 1] == passwordInfo.Letter) ^ passwordInfo.Password[passwordInfo.Max - 1] == passwordInfo.Letter);
 }
Example #4
0
        private static bool IsValidPart1(PasswordInfo passwordInfo)
        {
            int count = passwordInfo.Password.Count(c => c == passwordInfo.Letter);

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