#include "common.h" #include namespace aoc2022 { // which blueprint would maximize the number of opened geodes after 24 minutes // by figuring out which robots to build and when to build them. // geod <- obsi <- clay <- ore // ore ore struct blueprint { int idx = 0; int c_ore_r[2] = {0, 0}; // ore int c_clay_r[2] = {0, 0}; // ore int c_obsi_r[2] = {0, 0}; // ore + clay int c_geod_r[2] = {0, 0}; // ore + obsidian void get_number(const char** pp, int* d) { const char* p = *pp; while (*p >= '0' && *p <= '9') { *d = *d * 10 + *p - '0'; p++; } *pp = p; } void print() const noexcept { printf("%d: %d %d [%d,%d] [%d,%d]\n", idx, c_ore_r[0], c_clay_r[0], c_obsi_r[0], c_obsi_r[1], c_geod_r[0], c_geod_r[1]); } blueprint(line_view lv) { const char* p = lv.line; int i{0}; int* ps[7] = {&idx, c_ore_r, c_clay_r, c_obsi_r, c_obsi_r + 1, c_geod_r, c_geod_r + 1}; while (p < lv.line + lv.length) { if (*p >= '0' && *p <= '9') { get_number(&p, ps[i++]); } p++; } } }; std::pair day19(line_view); } // namespace aoc2022