#include #include #include #include #include "aoc.hpp" #include "aoc/utils.hpp" #include "fmt/format.h" #include "stb_image_write.h" using namespace aoc::types; using namespace std::string_view_literals; namespace rme { struct node; struct edge; struct edge { u64 n; u32 a; u32 b; }; struct node { u64 id; edge n; edge s; edge e; edge w; }; class graph { public: graph(std::string const& maze_str) : m_start(0), m_exit(0) { auto const lines = maze_str | std::views::split("\n"sv) | std::views::transform([](auto const& str) { return std::string_view(std::begin(str), std::end(str)); }) | std::views::filter([](auto const& str){ return !str.empty(); }) | std::ranges::to(); for (usize i = 0; i < lines.size(); ++i) { auto const& str = lines[i]; for (usize j = 0; j < str.size(); ++j) { auto const c = str[j]; node n{}; auto const id = u64((u64(i + 1) << 32) | (j + 1)); if (c == '#' || c == '\n') continue; if (c == 'S') m_start = id; if (c == 'E') m_exit = id; n.id = id; } } // for (usize i = 0; i < maze_str.size(); ++i) { // auto const c = maze_str[i]; // node n{}; // // if (c == '\n') { // ++row; // col = 1; // } // auto const id = u64((u64(row) << 32) | col++); // if (c == '#' || c == '\n') continue; // if (c == 'S') m_start = id; // if (c == 'E') m_exit = id; // // n.id = id; // } } private: u64 m_start; u64 m_exit; std::vector m_nodes{}; std::vector m_edges{}; }; } auto aoc24::day16([[maybe_unused]]std::span const& args) -> std::expected { // auto res = aoc::read_text("./dat/24/ex/16.txt"); auto res = aoc::read_text("./dat/24/re/16.txt"); if (!res) return std::unexpected(res.error()); auto const txt = *res; return {}; }