예제 #1
0
        public void Puzzle1()
        {
            var input = new FileReader()
                        .GetResource("AdventOfCode2020.Tests.Day19.PuzzleInput.txt");
            var tiles   = TileParser.Parse(input);
            var matches = EdgeMatchFinder.FindMatchingEdges(tiles);

            var corners = matches.Where(x => x.Matches.Count == 2);

            Assert.Equal(12519494280967, corners.Aggregate(1L, (current, match) => current * match.Tile.Id));
        }
예제 #2
0
        public void Puzzle2Example()
        {
            var input = new FileReader()
                        .GetResource("AdventOfCode2020.Tests.Day19.Puzzle1Example.txt");
            var tiles   = TileParser.Parse(input);
            var matches = EdgeMatchFinder.FindMatchingEdges(tiles);
            var map     = MapBuilder.BuildMap(MapBuilder.PlaceMap(matches));

            var maxX = map.Tiles.Values.Max(x => x.Position.X);
            var maxY = map.Tiles.Values.Max(x => x.Position.Y);

            for (var y = 0; y <= maxY; y++)
            {
                var spaces = "";
                for (var x = 0; x <= maxX; x++)
                {
                    var position = new Position(x, y);

                    spaces += map.Tiles[position.GetUniqueKey()].GetString();
                }

                _testOutputHelper.WriteLine(spaces);
            }
        }