Ejemplo n.º 1
0
 public void Problem()
 {
     Solver
     .CountReachableTiles(
         new Point(500, 0),
         ScriptDir.Combine("input.txt").ReadAllText())
     .ShouldBe((39162, 32047));
 }
Ejemplo n.º 2
0
        public void Part2()
        {
            var ops = Solver.DeduceOps(ScriptDir.Combine("input1.txt").ReadAllText());

            Solver
            .RunProgram(ops, ScriptDir.Combine("input2.txt").ReadAllText())
            .ShouldBe(594);
        }
Ejemplo n.º 3
0
        public void Day19()
        {
            var parsed = Parser.Parse(ScriptDir.Combine("../Day19/input.txt").ReadAllText());

            var text = Disassembler
                       .Disassemble(parsed.boundIP, parsed.instrs)
                       .StringJoin('\n');

            Debug.WriteLine(text);
        }
Ejemplo n.º 4
0
 char[,] ReadInputGrid() => ScriptDir.Combine($"{ScriptDir.FileName}.input.txt").ReadGrid();
Ejemplo n.º 5
0
        public void Main()
        {
            // sample

            Board.Si2("#######", // #######
                      "#.G...#", // #G....#   G(200)
                      "#...EG#", // #.G...#   G(131)
                      "#.#.#G#", // #.#.#G#   G(59)
                      "#..G#E#", // #...#.#
                      "#.....#", // #....G#   G(200)
                      "#######") // #######
            // Combat ends after 47 full rounds
            // Goblins win with 590 total hit points left
            // Outcome: 47 * 590 = 27730
            .ShouldBe((27730, 4988));

            Board.Sim("#######", //      #######
                      "#G..#E#", //      #...#E#   E(200)
                      "#E#E.E#", //      #E#...#   E(197)
                      "#G.##.#", // -->  #.E##.#   E(185)
                      "#...#E#", //      #E..#E#   E(200), E(200)
                      "#...E.#", //      #.....#
                      "#######") //      #######
            // Combat ends after 37 full rounds
            // Elves win with 982 total hit points left
            // Outcome: 37 * 982 = 36334
            .ShouldBe(36334);

            Board.Si2("#######", //      #######
                      "#E..EG#", //      #.E.E.#   E(164), E(197)
                      "#.#G.E#", //      #.#E..#   E(200)
                      "#E.##E#", // -->  #E.##.#   E(98)
                      "#G..#.#", //      #.E.#.#   E(200)
                      "#..E#.#", //      #...#.#
                      "#######") //      #######
            // Combat ends after 46 full rounds
            // Elves win with 859 total hit points left
            // Outcome: 46 * 859 = 39514
            .ShouldBe((39514, 31284));

            Board.Si2("#######", //      #######
                      "#E.G#.#", //      #G.G#.#   G(200), G(98)
                      "#.#G..#", //      #.#G..#   G(200)
                      "#G.#.G#", // -->  #..#..#
                      "#G..#.#", //      #...#G#   G(95)
                      "#...E.#", //      #...G.#   G(200)
                      "#######") //      #######
            // Combat ends after 35 full rounds
            // Goblins win with 793 total hit points left
            // Outcome: 35 * 793 = 27755
            .ShouldBe((27755, 3478));

            Board.Si2("#######", //      #######
                      "#.E...#", //      #.....#
                      "#.#..G#", //      #.#G..#   G(200)
                      "#.###.#", // -->  #.###.#
                      "#E#G#G#", //      #.#.#.#
                      "#...#G#", //      #G.G#G#   G(98), G(38), G(200)
                      "#######") //      #######
            // Combat ends after 54 full rounds
            // Goblins win with 536 total hit points left
            // Outcome: 54 * 536 = 28944
            .ShouldBe((28944, 6474));

            Board.Si2("#########", //      #########
                      "#G......#", //      #.G.....#   G(137)
                      "#.E.#...#", //      #G.G#...#   G(200), G(200)
                      "#..##..G#", //      #.G##...#   G(200)
                      "#...##..#", // -->  #...##..#
                      "#...#...#", //      #.G.#...#   G(200)
                      "#.G...G.#", //      #.......#
                      "#.....G.#", //      #.......#
                      "#########") //      #########
            // Combat ends after 20 full rounds
            // Goblins win with 937 total hit points left
            // Outcome: 20 * 937 = 18740
            .ShouldBe((18740, 1140));

            // problem

            var result = Board.Si2(ScriptDir.Combine("input.txt").ReadAllLines());

            //result.outcome3.Dump();
            //result.elvesOutcome.Dump();
            result.ShouldBe((188576, 57112));
        }
Ejemplo n.º 6
0
 public void Part2()
 {
     Solver
     .Sim(1000000000, ScriptDir.Combine("input.txt").ReadAllText())
     .ShouldBe(177004);
 }
Ejemplo n.º 7
0
 public void Part1()
 {
     Solver
     .Sim(10, ScriptDir.Combine("input.txt").ReadAllText())
     .ShouldBe(384480);
 }
Ejemplo n.º 8
0
 [Test, Ignore("Very slow")] // should just derive it
 public void Part1()
 {
     Solver
     .RunProgram(ScriptDir.Combine("input.txt").ReadAllText())
     .ShouldBe(2240);
 }
Ejemplo n.º 9
0
 public void Part1()
 {
     Solver
     .CountOpsMatching(3, ScriptDir.Combine("input1.txt").ReadAllText())
     .ShouldBe(521);
 }