#pragma once #include "common.h" #include #include namespace aoc2016 { struct maze { struct pos { int x; int y; friend bool operator<(pos p1, pos p2) { return p1.x < p2.x ? true : p1.x > p2.x ? false : p1.y < p2.y; } friend bool operator==(pos p1, pos p2) { return p1.x == p2.x && p1.y == p2.y; } }; char* ps = nullptr; int width; int height; std::set numbers; char& get(int x, int y) { return *(ps + width * y + x); } void load(int r, line_view lv) { const char* p = lv.line; int x{0}; while (p < lv.line + lv.length - 1) { get(x, r) = *p; if (*p >= '0' && *p <= '9') { numbers.insert({x, r}); } x++; p++; } } void print() { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { printf("%c", get(x, y)); } printf("\n"); } } maze(int mx, int my) : width(mx), height(my) { ps = (char*)malloc(width * height); memset(ps, 0, width * height); } }; std::pair day24(line_view); } // namespace aoc2016