예제 #1
0
        public void Part2_PuzzleLayoutTest()
        {
            var lines    = Example.Split(Environment.NewLine).ToList();
            var blocks   = SplitExtension.Split(lines, "");
            var tiles    = blocks.Select(b => new Tile(b.ToList())).ToList();
            var megaTile = new MegaTile(tiles);

            megaTile.ToString().Should().Be(@"
.#.#..#.##...#.##..#####
###....#.#....#..#......
##.##.###.#.#..######...
###.#####...#.#####.#..#
##.#....#.##.####...#.##
...########.#....#####.#
....#..#...##..#.#.###..
.####...#..#.....#......
#..#.##..#..###.#.##....
#.####..#.####.#.#.###..
###.#.#...#.######.#..##
#.####....##..########.#
##..##.#...#...#.#.#.#..
...#..#..#.#.##..###.###
.#.#....#.##.#...###.##.
###.#...#..#.##.######..
.#.#.###.##.##.#..#.##..
.####.###.#...###.#..#.#
..#.#..#..#.#.#.####.###
#..####...#.#.#.###.###.
#####..#####...###....##
#.##..#..#...#..####...#
.#.###..##..##..####.##.
...###...##...#...#..###
".Trim());
        }
예제 #2
0
        public void MonsterLocationExample()
        {
            var input = @".####...#####..#...###..
#####..#..#.#.####..#.#.
.#.#...#.###...#.##.##..
#.#.##.###.#.##.##.#####
..##.###.####..#.####.##
...#.#..##.##...#..#..##
#.##.#..#.#..#..##.#.#..
.###.##.....#...###.#...
#.####.#.#....##.#..#.#.
##...#..#....#..#...####
..#.##...###..#.#####..#
....#.##.#.#####....#...
..##.##.###.....#.##..#.
#...#...###..####....##.
.#.##...#.##.#.#.###...#
#.###.#..####...##..#...
#.###...#.##...#.######.
.###.###.#######..#####.
..##.#..#..#.#######.###
#.#..##.########..#..##.
#.#####..#.#...##..#....
#....##..#.#########..##
#...#.....#..##...###.##
#..###....##.#...##.##.#";

            var megaTile = new MegaTile(input);

            megaTile.NumberOfMonsters().Should().Be(2);
            megaTile.CountOfNonMonsterTiles().Should().Be(273);
        }
예제 #3
0
        public void MegaTileIterationExample()
        {
            var input = @".#.#..#.##...#.##..#####
###....#.#....#..#......
##.##.###.#.#..######...
###.#####...#.#####.#..#
##.#....#.##.####...#.##
...########.#....#####.#
....#..#...##..#.#.###..
.####...#..#.....#......
#..#.##..#..###.#.##....
#.####..#.####.#.#.###..
###.#.#...#.######.#..##
#.####....##..########.#
##..##.#...#...#.#.#.#..
...#..#..#.#.##..###.###
.#.#....#.##.#...###.##.
###.#...#..#.##.######..
.#.#.###.##.##.#..#.##..
.####.###.#...###.#..#.#
..#.#..#..#.#.#.####.###
#..####...#.#.#.###.###.
#####..#####...###....##
#.##..#..#...#..####...#
.#.###..##..##..####.##.
...###...##...#...#..###";

            var megaTile = new MegaTile(input);

            var result = Day20.IterateMegaTilePart2(megaTile);

            result.Should().Be(273);
        }
예제 #4
0
        public static long Part2(string input = null)
        {
            var lines = input == null?FileReader.ReadInputLines(Day).ToList() : input.Split(Environment.NewLine).ToList();

            var blocks = SplitExtension.Split(lines, "");
            var tiles  = blocks.Select(b => new Tile(b.ToList())).ToList();

            var neighbours = tiles.Select(t => t.PotentialNeighbours(tiles));
            var edges      = tiles.Where(t => t.PotentialNeighbours(tiles).ToList().Count(x => x == 0) >= 1);

            // edges.Count().Should().Be(44);

            var megaTile = new MegaTile(tiles);

            return(IterateMegaTilePart2(megaTile));
        }
예제 #5
0
 internal static long IterateMegaTilePart2(MegaTile megaTile)
 {
     var operationOrder = new[]