This commit is contained in:
Eric Mertens
2022-11-07 17:19:17 -08:00
parent 1b5607c8fe
commit 5de6db8780
7 changed files with 141 additions and 46 deletions

View File

@@ -40,6 +40,8 @@ auto CW(Coord) -> Coord;
/// Rotate counter-clockwise
auto CCW(Coord) -> Coord;
auto Norm1(Coord) -> std::int64_t;
/// Add two coordinates pairwise
auto operator+(Coord, Coord) -> Coord;

View File

@@ -1,5 +1,7 @@
#include <aocpp/Coord.hpp>
#include <cstdlib>
namespace aocpp {
auto Draw(std::ostream & out, std::map<Coord, std::int64_t> image) -> void {
@@ -65,6 +67,10 @@ auto CCW(Coord c) -> Coord {
return c;
}
auto Norm1(Coord c) -> std::int64_t {
return std::abs(c.x) + std::abs(c.y);
}
auto operator+(Coord a, Coord b) -> Coord {
return {a.x + b.x, a.y + b.y};
}