#include namespace aocpp { auto Draw(std::ostream & out, std::map image) -> void { std::int64_t minX = 0, maxX = 0, minY = 0, maxY = 0; for (auto&& [k, _] : image) { auto [x,y] = k; minX = std::min(minX, x); maxX = std::max(maxX, x); minY = std::min(minY, y); maxY = std::max(maxY, y); } for (std::int64_t y = minY; y <= maxY; y++) { for (std::int64_t x = minX; x <= maxX; x++) { auto it = image.find({x,y}); if (image.end() == it) { out << "░"; } else switch (it->second) { case 0: out << "▒"; break; case 1: out << "▓"; break; case 2: out << "■"; break; case 3: out << "◆"; break; case 4: out << "●"; break; default: out << "★"; break; } } out << "\n"; } } auto Up(Coord c) -> Coord { c.y -= 1; return c; } auto Down(Coord c) -> Coord { c.y += 1; return c; } auto Left(Coord c) -> Coord { c.x -= 1; return c; } auto Right(Coord c) -> Coord { c.x += 1; return c; } auto Invert(Coord c) -> Coord { return {c.y, c.x}; } auto CW(Coord c) -> Coord { c = Invert(c); c.x = -c.x; return c; } auto CCW(Coord c) -> Coord { c = Invert(c); c.y = -c.y; return c; } auto operator+(Coord a, Coord b) -> Coord { return {a.x + b.x, a.y + b.y}; } auto operator-(Coord a, Coord b) -> Coord { return {a.x - b.x, a.y - b.y}; } auto operator+=(Coord & a, Coord b) -> Coord & { a = a + b; return a; } auto operator-=(Coord & a, Coord b) -> Coord & { a = a - b; return a; } auto operator<<(std::ostream & out, Coord c) -> std::ostream & { return out << "(" << c.x << "," << c.y << ")"; } } // namespace