Esempio n. 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());
        }
Esempio n. 2
0
        public static long Part1(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 corners    = tiles.Where(t => t.NumberOfNeighbours(tiles) == 2);

            corners.Count().Should().Be(4);
            return(corners.Aggregate(1L, (a, x) => a * x.Id));
        }
Esempio n. 3
0
        public async Task <long> Part2(string input = null)
        {
            var lines = await File.ReadAllLinesAsync("inputs\\20.txt");

            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));
        }
Esempio n. 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));
        }