Example #1
0
        public void Part_1_example_mutations()
        {
            var grid  = Parse(Example);
            var rules = new Part1Rules(grid);

            Assert.True(rules.Apply());
            Assert.Equal(@"#.##.##.##
#######.##
#.#.#..#..
####.##.##
#.##.##.##
#.#####.##
..#.#.....
##########
#.######.#
#.#####.##", grid.ToString());

            Assert.True(rules.Apply());
            Assert.Equal(@"#.LL.L#.##
#LLLLLL.L#
L.L.L..L..
#LLL.LL.L#
#.LL.LL.LL
#.LLLL#.##
..L.L.....
#LLLLLLLL#
#.LLLLLL.L
#.#LLLL.##", grid.ToString());
        }
Example #2
0
        private static int Part1(ReadOnlyMemory <string> input)
        {
            var grid = Parse(input);

            var rules = new Part1Rules(grid);

            while (rules.Apply())
            {
            }

            return(grid.Seats().Count(seat => seat.Occupied));
        }