private bool IsValid(PasswordWithPolicy passwordWithPolicy)
        {
            var count = passwordWithPolicy.Password
                        .Count(c => c == passwordWithPolicy.RequiredCharacter);

            return(passwordWithPolicy.MinOccurences <= count &&
                   count <= passwordWithPolicy.MaxOccurences);
        }
        private bool IsValidPart2(PasswordWithPolicy passwordWithPolicy)
        {
            var passwordArray = passwordWithPolicy.Password.ToCharArray();
            var char1         = passwordArray[passwordWithPolicy.Position1 - 1];
            var char2         = passwordArray[passwordWithPolicy.Position2 - 1];

            var char1MatchCount = char1 == passwordWithPolicy.RequiredCharacter ? 1 : 0;
            var char2MatchCount = char2 == passwordWithPolicy.RequiredCharacter ? 1 : 0;

            return(char1MatchCount + char2MatchCount == 1);
        }