Exemple #1
0
        static bool EvalPassword1(Day2_Common.Policy policy)
        {
            int cntr = 0;

            foreach (char ch in policy.password)
            {
                if (ch == policy.letter)
                {
                    cntr++;
                }
            }

            return(cntr >= policy.a && cntr <= policy.b);
        }
Exemple #2
0
        static bool EvalPassword2(Day2_Common.Policy policy)
        {
            int cntr = 0;

            if (policy.password[policy.a - 1] == policy.letter)
            {
                cntr++;
            }
            if (policy.password[policy.b - 1] == policy.letter)
            {
                cntr++;
            }

            return(cntr == 1);
        }