#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(std::istream & in, std::ostream & out) -> void { auto machine = Machine{ParseStream(in)}; out << "Part 1: " << Compute(machine, 0).size() << "\nPart 2\n"; Draw(out, Compute(std::move(machine), 1)); }