public void CountValidPasswordWithExampleOfPartOne()
        {
            string[] passwords           = new[] { "1-3 a: abcde", "1-3 b: cdefg", "2-9 c: ccccccccc" };
            int      validPasswordsCount = PasswordPhilosophy.GetNumbersValidPasswordsContainsOccurrenceCharacter(passwords);

            Assert.IsTrue(validPasswordsCount == 2);
        }
예제 #2
0
        internal static async Task Main(string[] args)
        {
            string[] passwords = await FileUtils.ReadFileContentFromPathAsync("AOC-2020-D-2-input.txt");

            int countValidPasswordPartOne = 0;

            if (passwords != null && passwords.Length > 0)
            {
                countValidPasswordPartOne = PasswordPhilosophy.GetNumbersValidPasswordsContainsOccurrenceCharacter(passwords);
            }
            int countValidPasswordPartTwo = 0;

            if (passwords != null && passwords.Length > 0)
            {
                countValidPasswordPartTwo = PasswordPhilosophy.GetNumbersValidPasswordsContainsExactlyOccurrenceCharacter(passwords);
            }

            Console.WriteLine("====================================================");
            Console.WriteLine("ADVENT OF CODE 2020 - DAY 2: PASSWORD PHILOSOPHY");
            Console.WriteLine("====================================================");
            Console.WriteLine("----- PART 1 -----");
            Console.WriteLine($"Result: {countValidPasswordPartOne}");
            Console.WriteLine("----- PART 2 -----");
            Console.WriteLine($"Result: {countValidPasswordPartTwo}");
        }