コード例 #1
0
        public static bool IsValid(string input)
        {
            var(digit1, digit2, letter, password) = PolicyValidator.Parse(input);

            var count   = password.Count(x => x == letter);
            var isValid = count >= digit1 && count <= digit2;

            return(isValid);
        }
コード例 #2
0
        public static bool IsValid2(string input)
        {
            var(digit1, digit2, letter, password) = PolicyValidator.Parse(input);

            var isPos1  = password[digit1 - 1] == letter;
            var isPos2  = password[digit2 - 1] == letter;
            var isValid = isPos1 ^ isPos2;

            return(isValid);
        }