#include #include #include #include #include #include #include using namespace aocpp; using namespace intcode; namespace { auto Compute(Machine machine, ValueType start) -> std::map { Coord here {0,0}; std::map paint {{here,start}}; Coord dir {0, -1}; bool next_color = true; Run(machine, [&]() { return paint[here]; }, [&](auto o) { if (next_color) { paint[here] = o; } else { dir = (o ? CW : CCW)(dir); here += dir; } next_color = !next_color; }); return paint; } } // namespace auto main(int argc, char** argv) -> int { auto machine = Machine{ParseStream(*aocpp::Startup(argc, argv))}; std::cout << "Part 1: " << Compute(machine, 0).size() << "\nPart 2\n"; Draw(std::cout, Compute(std::move(machine), 1)); }