diff --git a/day02.cpp b/day02.cpp index 2358984..cacfcca 100644 --- a/day02.cpp +++ b/day02.cpp @@ -16,8 +16,8 @@ auto Compute(Machine machine, ValueType x, ValueType y) { } // namespace -auto main() -> int { - auto machine = Machine{ParseStream(std::cin)}; +auto main(int argc, char** argv) -> int { + auto machine = Startup(argc, argv); std::cout << "Part 1: " << Compute(machine, 12, 2) << std::endl; diff --git a/day05.cpp b/day05.cpp index 0929a21..6885cfc 100644 --- a/day05.cpp +++ b/day05.cpp @@ -16,8 +16,8 @@ auto Compute(Machine machine, ValueType d) -> ValueType { } // namespace -auto main() -> int { - auto machine = Machine{ParseStream(std::cin)}; +auto main(int argc, char** argv) -> int { + auto machine = Startup(argc, argv); std::cout << "Part 1: " << Compute(machine, 1) << std::endl; std::cout << "Part 2: " << Compute(std::move(machine), 5) << std::endl; } diff --git a/day07.cpp b/day07.cpp index 79e97a4..65ee93c 100644 --- a/day07.cpp +++ b/day07.cpp @@ -58,8 +58,8 @@ auto optimize(Machine machine, std::vector params, F f) { } // namespace -auto main() -> int { - auto machine = Machine{ParseStream(std::cin)}; +auto main(int argc, char** argv) -> int { + auto machine = Startup(argc, argv); std::cout << "Part 1: " << optimize(machine, {0, 1, 2, 3, 4}, compute1) << std::endl; std::cout << "Part 2: " << optimize(std::move(machine), {5, 6, 7, 8, 9}, compute2) << std::endl; } diff --git a/day09.cpp b/day09.cpp index 844e262..0823756 100644 --- a/day09.cpp +++ b/day09.cpp @@ -16,8 +16,8 @@ auto Compute(Machine machine, ValueType d) -> ValueType { } // namespace -auto main() -> int { - auto machine = Machine{ParseStream(std::cin)}; +auto main(int argc, char** argv) -> int { + auto machine = Startup(argc, argv); std::cout << "Part 1: " << Compute(machine, 1) << std::endl; std::cout << "Part 2: " << Compute(std::move(machine), 2) << std::endl; } diff --git a/day11.cpp b/day11.cpp index 4c43d40..8db1ad2 100644 --- a/day11.cpp +++ b/day11.cpp @@ -35,8 +35,8 @@ auto Compute(Machine machine, ValueType start) } // namespace -auto main() -> int { - auto machine = Machine{ParseStream(std::cin)}; +auto main(int argc, char** argv) -> int { + auto machine = Startup(argc, argv); std::cout << "Part 1: " << Compute(machine, 0).size() << "\nPart 2\n"; Draw(std::cout, Compute(std::move(machine), 1)); } diff --git a/day13.cpp b/day13.cpp index cf931a1..e1b5d3d 100644 --- a/day13.cpp +++ b/day13.cpp @@ -57,8 +57,8 @@ auto Compute2(Machine machine) { } // namespace -auto main() -> int { - auto machine = Machine{ParseStream(std::cin)}; +auto main(int argc, char** argv) -> int { + auto machine = Startup(argc, argv); std::cout << "Part 1: " << Compute1(machine) << std::endl; std::cout << "Part 2: " << Compute2(std::move(machine)) << std::endl; } diff --git a/day15.cpp b/day15.cpp index 148138a..eac9837 100644 --- a/day15.cpp +++ b/day15.cpp @@ -88,8 +88,8 @@ auto Compute(std::map world) -> std::pair { } // namespace -auto main() -> int { - auto [p1,p2] = Compute(Explore(Machine{ParseStream(std::cin)})); +auto main(int argc, char** argv) -> int { + auto [p1,p2] = Compute(Explore(Startup(argc, argv))); std::cout << "Part 1: " << p1 << std::endl; std::cout << "Part 2: " << p2 << std::endl; } diff --git a/day23.cpp b/day23.cpp index 4d33971..0dbc6fa 100644 --- a/day23.cpp +++ b/day23.cpp @@ -54,9 +54,8 @@ auto Interact(Ethernet & ethernet, Machine & m, std::optional p) -> voi } // namespace -auto main() -> int { - std::ifstream fin { "/Users/emertens/Source/advent/inputs/2019/23.txt" }; - auto machines = BuildNetwork(Machine{ParseStream(fin)}); +auto main(int argc, char** argv) -> int { + auto machines = BuildNetwork(Startup(argc, argv)); auto ethernet = Ethernet{}; std::optional part1; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index dcf7c18..93ec6be 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,2 +1,2 @@ -add_library(intcode src/Coord.cpp src/Parser.cpp src/Interpreter.cpp src/Machine.cpp) +add_library(intcode src/Coord.cpp src/Parser.cpp src/Interpreter.cpp src/Machine.cpp src/Startup.cpp) target_include_directories(intcode PUBLIC include) diff --git a/lib/include/intcode/intcode.hpp b/lib/include/intcode/intcode.hpp index fb11a8f..44cd87f 100644 --- a/lib/include/intcode/intcode.hpp +++ b/lib/include/intcode/intcode.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #endif