#include #include #include #include #include using namespace intcode; namespace { using Coord = std::pair; auto Compute(Machine machine, ValueType start) -> std::map { Coord here {0,0}; std::map paint {{here,start}}; ValueType dx = 1; ValueType dy = 0; for (;;) { auto effect = machine.Step(); if (std::holds_alternative(effect)) { return paint; } std::get(effect).pos = paint[here]; auto color = std::get(machine.Step()).val; auto dir = std::get(machine.Step()).val; paint[here] = color; std::swap(dx, dy); if (dir) { dx = -dx; } else { dy = -dy; } here.first += dx; here.second += dy; } } auto Draw(std::map image) { ValueType minX = 1000, maxX = -1000, minY = 1000, maxY = -1000; } } // namespace auto main() -> int { auto machine = Machine{ParseStream(std::cin)}; std::cout << "Part 1: " << Compute(machine, 0).size() << std::endl; Draw(Compute(std::move(machine), 1)); }