// Solutions to the Advent Of Code 2024. // Copyright (C) 2024-2025 Stefan Müller // // This program is free software: you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation, either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with // this program. If not, see . #include #include // Solver implementations in day order. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REQUIRE_MESSAGE(cond, msg) if (!(cond)) { INFO(msg); REQUIRE(cond); } TEST_CASE("[HistorianHysteriaTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 2176849, 23384288); } SECTION("ExampleData") { test.runExample(std::make_unique(), 11, 31); } } TEST_CASE("[RedNosedReportsTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 472, 520); } SECTION("ExampleData") { test.runExample(std::make_unique(), 2, 4); } } TEST_CASE("[MullItOverTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 187833789, 94455185); } SECTION("ExampleData") { test.runExample(std::make_unique(), 161, 48); } } TEST_CASE("[CeresSearchTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 2462, 1877); } SECTION("ExampleData") { test.runExample(std::make_unique(), 18, 9); } } TEST_CASE("[PrintQueueTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 5087, 4971); } SECTION("ExampleData") { test.runExample(std::make_unique(), 143, 123); } } TEST_CASE("[GuardGallivantTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 4665, 1688); } SECTION("ExampleData") { test.runExample(std::make_unique(), 41, 6); } } TEST_CASE("[BridgeRepairTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 12839601725877, 149956401519484); } SECTION("ExampleData") { test.runExample(std::make_unique(), 3749, 11387); } } TEST_CASE("[ResonantCollinearityTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 426, 1359); } SECTION("ExampleData") { test.runExample(std::make_unique(), 14, 34); } } TEST_CASE("[DiskFragmenterTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 6401092019345, 6431472344710); } SECTION("ExampleData") { test.runExample(std::make_unique(), 1928, 2858); } } TEST_CASE("[HoofItTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 611, 1380); } SECTION("ExampleData") { test.runExample(std::make_unique(), 36, 81); } } TEST_CASE("[PlutonianPebblesTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 220999, 261936432123724); } SECTION("ExampleData") { test.runExample(std::make_unique(), 55312, 65601038650482); } } TEST_CASE("[GardenGroupsTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 1477762, 923480); } SECTION("ExampleData") { test.runExample(std::make_unique(), 1930, 1206); } SECTION("ExampleData2") { test.runExample(std::make_unique(2), 140, 80); } SECTION("ExampleData3") { test.runExample(std::make_unique(3), 772, 436); } SECTION("ExampleData4") { test.runExamplePart2(std::make_unique(4), 236); } SECTION("ExampleData5") { test.runExamplePart2(std::make_unique(5), 368); } } TEST_CASE("[ClawContraptionTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 36571, 85527711500010); } SECTION("ExampleData") { test.runExample(std::make_unique(), 480, 875318608908); } } TEST_CASE("[RestroomRedoubtTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 224969976, 7892); } SECTION("ExampleData") { test.runExample(std::make_unique(11, 7, false), 12, 0); } } TEST_CASE("[WarehouseWoesTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 1515788, 1516544); } SECTION("ExampleData") { test.runExample(std::make_unique(), 10092, 9021); } SECTION("ExampleData2") { test.runExamplePart1(std::make_unique(2), 2028); } } TEST_CASE("[ReindeerMazeTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 72400, 435); } SECTION("ExampleData") { test.runExample(std::make_unique(), 7036, 45); } SECTION("ExampleData2") { test.runExample(std::make_unique(2), 11048, 64); } } TEST_CASE("[ChronospatialComputerTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), "5,0,3,5,7,6,1,5,4", 164516454365621); } SECTION("ExampleData") { test.runExamplePart1(std::make_unique(), "4,6,3,5,6,3,5,2,1,0"); } SECTION("ExampleInstruction1") { auto solver = std::make_unique(); ChronospatialComputerState state{}; state.registers[2] = 9; solver->runProgram({ 2, 6 }, state); REQUIRE(1 == state.registers[1]); } SECTION("ExampleInstruction2") { auto solver = std::make_unique(); ChronospatialComputerState state{}; state.registers[0] = 10; solver->runProgram({ 5, 0, 5, 1, 5, 4 }, state); REQUIRE("0,1,2" == state.output.str()); } SECTION("ExampleInstruction3") { auto solver = std::make_unique(); ChronospatialComputerState state{}; state.registers[0] = 2024; solver->runProgram({ 0, 1, 5, 4, 3, 0 }, state); REQUIRE(0 == state.registers[0]); REQUIRE("4,2,5,6,7,7,7,7,3,1,0" == state.output.str()); } SECTION("ExampleInstruction4") { auto solver = std::make_unique(); ChronospatialComputerState state{}; state.registers[1] = 29; solver->runProgram({ 1, 7 }, state); REQUIRE(26 == state.registers[1]); } SECTION("ExampleInstruction5") { auto solver = std::make_unique(); ChronospatialComputerState state{}; state.registers[1] = 2024; state.registers[2] = 43690; solver->runProgram({ 4, 0 }, state); REQUIRE(44354 == state.registers[1]); } } TEST_CASE("[RamRunTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 248, "32,55"); } SECTION("ExampleData") { test.runExample(std::make_unique(7, 12), 22, "6,1"); } } TEST_CASE("[LinenLayoutTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 272, 1041529704688380); } SECTION("ExampleData") { test.runExample(std::make_unique(), 6, 16); } } TEST_CASE("[LanPartyTests]") { TestContext test; SECTION("FullData") { test.runFull(std::make_unique(), 1230, ""); } SECTION("ExampleData") { test.runExample(std::make_unique(), 7, ""); } }