Exemplo n.º 1
0
        public void parse_input_line()
        {
            var input = new[]
            {
                "1-3 a: abcde",
                "1-3 b: cdefg",
                "2-9 c: ccccccccc"
            };

            var output = AOC_2020_Day02_Answer.Parse(input);

            output.Should().BeEquivalentTo(
                new PasswordRule
            {
                MinNum      = 1,
                MaxNum      = 3,
                CharToCheck = 'a',
                Password    = "******"
            },
                new PasswordRule
            {
                MinNum      = 1,
                MaxNum      = 3,
                CharToCheck = 'b',
                Password    = "******"
            },
                new PasswordRule
            {
                MinNum      = 2,
                MaxNum      = 9,
                CharToCheck = 'c',
                Password    = "******"
            }
                );
        }
Exemplo n.º 2
0
        public void AOC_2020_Day02b()
        {
            var input = File.ReadAllText(".//Content2//2020/Day02.txt")
                        .Split(Environment.NewLine);
            var output = AOC_2020_Day02_Answer.Parse(input);
            var answer = AOC_2020_Day02_Answer.CountRulesThatPassv2(output);

            answer.Should().Be(388);
        }
Exemplo n.º 3
0
        public void count_rules_that_pass()
        {
            var input = new[]
            {
                "1-3 a: abcde",
                "1-3 b: cdefg",
                "2-9 c: ccccccccc"
            };

            var output = AOC_2020_Day02_Answer.Parse(input);
            var answer = AOC_2020_Day02_Answer.CountRulesThatPass(output);

            answer.Should().Be(2);
        }