finish day 4

This commit is contained in:
2025-12-04 17:41:43 -05:00
parent debf18936b
commit 9282b3d531
5 changed files with 313 additions and 0 deletions

View File

@@ -8,4 +8,5 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS true)
add_executable(cpp_tests add_executable(cpp_tests
doctest.h doctest.h
run_tests.cpp run_tests.cpp
utils.h
) )

152
day4.cpp Normal file
View File

@@ -0,0 +1,152 @@
//
// Created by Grant Horner on 12/4/25.
//
#include <ranges>
#include <string>
#include <vector>
#include "doctest.h"
#include "utils.h"
namespace day4 {
const std::string sample =
"..@@.@@@@.\n"
"@@@.@.@.@@\n"
"@@@@@.@.@@\n"
"@.@@@@..@.\n"
"@@.@@@@.@@\n"
".@@@@@@@.@\n"
".@.@.@.@@@\n"
"@.@@@.@@@@\n"
".@@@@@@@@.\n"
"@.@.@@@.@.\n";
enum class Point : char {
Paper = '@',
Empty = '.',
};
template<typename T>
std::array<char, 8> get_surrounding(const std::vector<T> &lines, size_t x, size_t y) noexcept {
std::array<char, 8> points = {};
size_t i = 0;
for (int dy = -1; dy < 2; ++dy) {
if (y + dy < 0 || y + dy >= lines.size()) { continue; }
for (int dx = -1; dx < 2; ++dx) {
if (x + dx < 0 || x + dx >= lines[0].size()) { continue; }
if (dx == 0 && dy == 0) continue;
points[i] = lines[y + dy][x + dx];
i++;
}
}
return points;
}
uint32_t solve_first(const std::string_view input) noexcept {
const auto lines = std::string_view{input}
| std::views::split('\n')
| std::views::transform(to_string_view)
| std::views::filter([](const auto s) { return !s.empty(); })
| std::ranges::to<std::vector>();
uint32_t accessible = 0;
for (size_t y = 0; y < lines.size(); ++y) {
for (size_t x = 0; x < lines[0].size(); ++x) {
const auto c = lines[y][x];
if (c != '@') continue;
size_t num_paper = 0;
for (const char p: get_surrounding(lines, x, y)) {
if (p == '@') {
num_paper++;
}
if (num_paper == 4) {
break;
}
}
if (num_paper < 4) {
accessible++;
}
}
}
return accessible;
}
template<typename T>
std::vector<std::tuple<size_t, size_t> > remove_paper(const std::vector<T> &lines) {
std::vector<std::tuple<size_t, size_t> > removable = {};
for (size_t y = 0; y < lines.size(); ++y) {
for (size_t x = 0; x < lines[0].size(); ++x) {
const auto c = lines[y][x];
if (c != '@') continue;
size_t num_paper = 0;
for (const char p: get_surrounding(lines, x, y)) {
if (p == '@') {
num_paper++;
}
if (num_paper == 4) {
break;
}
}
if (num_paper < 4) {
removable.emplace_back(x, y);
}
}
}
return removable;
}
uint32_t solve_second(const std::string_view input) {
std::vector<std::string> lines = std::string_view{input}
| std::views::split('\n')
| std::views::transform([](const auto r) {
return std::string(r.data(), r.size());
})
| std::views::filter([](const auto &s) { return !s.empty(); })
| std::ranges::to<std::vector>();
bool removed = false;
uint32_t total_removed = 0;
do {
removed = false;
const auto removable = remove_paper(lines);
if (!removable.empty()) {
removed = true;
}
for (auto [x, y]: removable) {
lines[y][x] = '.';
total_removed++;
}
} while (removed);
return total_removed;
}
TEST_SUITE_BEGIN("Day 4");
TEST_CASE("solves first sample") {
CHECK(solve_first(sample) == 13);
}
TEST_CASE("solves first puzzle") {
CHECK(solve_first(read_file("day4input.txt")) == 1626);
}
TEST_CASE("solves second sample") {
CHECK(solve_second(sample) == 43);
}
TEST_CASE("solves second puzzle") {
CHECK(solve_second(read_file("day4input.txt")) == 9173);
}
TEST_SUITE_END();
}

140
day4input.txt Normal file
View File

@@ -0,0 +1,140 @@
@.@.@@@@@@@@.@.@@@@@@@@@@@@@.@@@@..@@@@.@@...@@@@.@@...@@@@.@@@.@@@@@@..@.@.@@@@.@..@@..@@.@.....@@@@..@@@@@@@@@@@.@@.@.@@@@.@..@@@@..@@@.@.
.@.@@.@@@..@@@.@@..@@@@@.@.@@@@@.@@.@@.@@..@...@@@@@@@...@@..@..@@@@@@.@@@@..@..@@@@@.@.@.@.@@@@.@.@.@.@@@@@@@@...@@..@.@.@@@@@...@@..@@@@@.
.@@.@@@.@.@.@@.@@@@@@@@@@..@..@@..@@..@.@@..@@.@@.@.@@.@..@@@@@.@@@@@@@..@@@.@.@..@.@@@@@@@..@@..@@.@.@.@@.....@@@..@@.@..@@.@...@@@..@.@@@@
....@@@@@@..@@@..@@@@@.@.@.@.@@@@@@..@.@@@.@....@.@@@@@.@@.@@@@@@.@@@@@@.@@..@@@@...@@@@@@@@@@..@@.@@.@...@.@.@@@@.@.@@@@.@.@@.@@.@..@.@...@
@@.@@.@..@@@......@@.@.@@.@@.@.@..@..@@@..@..@@@@@@..@@.@@@@@@@.@.@@@..@.@.@.@.@@@@.@@...@.@@@..@@@@..@@@@@@@@@@@.@@.@@@@@@@.@@@@@..@..@..@@
@@@@@@@.@.@.@@@@@.@@@@@@@@@.@@@@@@..@@@@@@...@.@..@.@.@@@@@@@..@.@@@@@@@.@@@@@.@@@.@...@@.@..@@@@.@@@@@@..@@@@@.@@@.@....@@..@.@.@@@@@@@...@
@@.@@@@.@.@@@.@@@..@@@@@.@@@@@@@@@@.@@@@.@.@@@@@@@.@....@@@.@.@@@@.@....@@..@@@@@..@@@@..@@....@@@@.@@@..@@@@@@.@..@@.@@@@.@@@@..@@@@.@@@..@
..@@..@@@.@@..@@.@@@.@..@@@.@.@@@..@@@@@@.@.@@@@.@.@@..@@..@.@.@@@@........@@@@.@@@.@@.@@@@@.@@@.@@..@.@@.@.@@@.@@@@@.@@@.@..@@@@..@.@@.@@.@
@@.@@...@..@@@@@.@@@@.@@@.@@..@.@...@@..@@@@@..@.@@@@@@@..@@@@.@@@@@.@.@@@.@@@....@.@@@.@.@.......@@.@@@..@..@@@@@@@...@..@@.@@@@@.@@@@@..@.
...@@@@.@...@@.@.@..@@.@@@..@@.@@@..@...@@@.@..@@@@@..@@.@@..@@...@@.@..@@.@@@@@@@@.@.@.@@@@@@@@@.@...@..@@@@..@@.@..@.@@@@@@..@@.@@@@..@..@
@.@.@@@@.@.@.@.@@..@.@@@.@@@...@.@.@.@@.@@@@@@......@@.@@.@@@@@.@@.@@@@....@...@@@@.@@@@...@.@@.@.@@@@.@@@@.@....@@@.@@@@@@@@@@.@@@@.@@@@@..
@.@@@@@.@.@..@@..@...@@@.@..@.@@@@@@.@@@@@.@@.@.@.@@...@@@.@@.@.@@@...@.@.@..@.@@..@@...@@@.@.@..@@@@.@@@@..@@@@@.@.@..@..@.@.@@.@....@....@
@@@@@@@@@.@.@.....@@....@@@.@@.@@@@@.@@.@.@@@@@..@..@@.@...@.@.@@@.@.@@@@@@..@@.@@....@..@@.@.@@@@.@@.@..@.@@@@.@@.@@@..@@.@@...@@..@@.@@.@.
.@@@..@..@@.@@@.@@@@.@@@.@..@@.@@@..@@@@.@@@@.@.@@@@@@@@@.@.@@@@.@@@.....@@@@@.@@@@@@@@@@@..@@..@.@@@@...@@@@.@@@@@@@...@@@@@@@@@@@.@@@....@
@@@@@..@@..@@.@@@@.@.@@@@@.@@.@@.@..@...@@@.@@.@@@@@@.@.@@@..@@@@@@@@@@.@@.@..@.@@@..@.@.@.@...@@@@@..@@@.@@@.@@@....@@.@.@..@@.@@.@@.@@..@.
@@@@@@@@.@@@@.@@@..@..@.@@..@@.@..@@@.@.@@...@@@@@.@@@..@@@@@@@@..@@@@...@.@..@.@@@@@@..@.@....@..@@@@.@@@@@@.@@@....@@.@@@@.@@@@@..@@.@..@.
@@@@.@@@.@@..@..@@@..@@@@@@@@@@@..@.@@@..@@@@..@@@@@@@@@@@@@@..@@@..@@@@@@@@@.@..@...@@@.@@.@.@......@@.@..@@@.@...@.@.@@@.@@@@...@@.@.@..@@
@@.@.@@@@@@@@.@@@..@.....@..@.@@.@@@@....@@@...@@@@@@@@@....@.@@@@..@@.@@@@@.@.@@.@@.@.@@@@@@@@@@@.@.@.@@.@@@@..@.@.@.@@@.@@@.@@.@@...@.@@@.
@..@@.@@.@@@..@@.@@@@@@.@.@@.@.@.....@..@..@@.@@.@@@@@@@@..@@.@@@@@@@.@@@@...@@@.@@..@@..@..@@@.@.....@.@@.@@@@@...@@.@@@.@@@.@@@.@@..@.@.@@
@@@@.@@@@@.@.@@.@...@.@@.@@@@@@@@@.@@@@@@.@@..@@@.@@@..@@.@.@@.@@@@@@.@@@.@..@@.@@.@@..@.@.@@@.@@@@@.@@.@...@@@.@@.@@@@@.@@..@@@@..@.@@@.@@@
.@@@@.@....@..@@@@@@.@@@.@@@.@@@@@.@..@@@@@...@@@@.@@.@@@@@@@@.@@@@.@@@.@@..@...@@..@@.@...@@@.@@@@@@...@.@@@@@@@@@..@@.@@@.@@@.@.@@@.@..@@@
@@@..@@@@.@@..@@@@..@@@.@..@....@@.@..@@.@..@@@@....@@.@.@.@.@@.@@@@@@@..@@@.@@@@..@@...@@.@@@.@@@@@....@@@@.@@..@@@.@@.@@..@@.@@.@...@@@..@
@@@@@.@@@...@.@@..@.@@.@@..@..@.@.@@..@.....@@@@..@.@@@@.@@.@@@@@@@@@.@@..@@@@@@..@@..@..@.@@@@@@..@..@....@@@@@.@@@@@@..@@@@@@@@.@@..@@.@..
.@...@@@@@@.@@@.@@@.@@@.@.@@@.@@@@@@@....@@@@@@.@..@@@.@@@@.@@@.@..@@@@.@@@..@.@.@@@@..@.@.@@...@@@.@.@@@.@.@@@@@@@.@@..@@.@.@.@.@.@@@@.@@@@
@@@.@@.@@@@@@.@@@@@..@@@.@.@..@.@@@@.@.....@@@.@......@@@.@...@@@..@@@..@@.@...@.@@@@.@.@@.@@@@@@@@.@@.@@@.@.@...@@@@..@.@.@.@@@..@@@@@@.@@@
@..@@.@@@@@@@@@@.@@..@.@.@@@@...@@..@..@@.@@@@.@.@....@.@@.@@@.@.@@.@.@.@@.@@@@@@@@@@@...@@@.@..@@.@.@@@@@@@@@@.@@.@.@@@.@@.@@@.@.@@@...@.@.
@@@@@@.@@@..@.@@@@@@.@@.@.@@@..@@@@@@@@.@.@@@@.@@@@@@@.@@@.@@@@@@..@@@@.@.@@@@@..@@@@@@@@@@.@.@@.@...@@.@@...@@@@.@@.@.@.@@@@@.@@@.@....@@@@
.@@@@@@...@@.@.@@@.@@@..@.@@@@@@@@..@.@@@@@@@@....@@@@@@@.@@.@@@@@@@..@@....@@@@@@@...@..@.@...@@.@@@.@@@@.@.@@@.@.@@@@@@@.@@@@@@@@@@@.@@@@@
@..@@@@.@@@@@.....@@.@@.@@@@@@.@..@.@@.@@.@@@@@.@@@@@@@...@.@.@........@..@@..@.@@@.@.@@.@@@.@@@.@.@.@@@.@..@@@@@..@@..@@.@.@@..@.@@.@@@.@@@
...@.@@@.@@.@.@....@@@@@..@..@@@..@@@@@..@..@@@.@...@.@@.@@.@.@@..@.@@@...@.@@@@...@.@..@@.@@.@@@.@..@@.@@.@@.@@..@@.@.@.@.@.@@@@@@@@@...@@.
...@.@.@.@.@..@@@..@.@@...@@@@@@@@@@.@..@..@.@@.@.@@@@.@@@@@..@.@.@@@...@@..@@@@......@@@.@@@@.@@.@@...@@@@@@@@@@@@@@.@.@@.@@@@.@@..@.....@@
@.@.@.@@@...@@.@@@@@....@@.@.@.@@.@@@@.@@@@..@@.@@@@.@@.@@@@@.@@@.@@@@@@.@@@.@@.@.@...@.@.@.@@@.@@..@@@.@@..@@@.@@@..@..@@@@..@@.@..@.@@@@@.
@@.@@@...@@..@..@@@.@@@@.@@@@.@@@.@@@@..@@@@@@@@...@@..@@@@..@.@@.@@@@@@...@@@@@@@..@.@@.@@@...@@.@@...@@@@@.@..@@@.@@@.@@@@.@@@@..@.@@@@.@.
@..@@@@.@@.@@@@.@@@.@.@@@.@@@.@@@@..@@.@@..@@@.@....@.@.@@@@.@@@.@.@.@@.@@..@.@@.@@@@@@@@...@@@@@..@@@.@@@@@@.@@@@@@.@@.@@@.@@..@@@@@@@@@.@.
@@@...@@@.@@@@@@.@.@@@@@..@.@@.@@.@@.@.@.@@@@@@.@..@@.@@@.@..@.@@@@@@@@@.@@@@@.@@@.@.@.@@.....@@@@.@...@@@@@.@@...@@@@@@@@@@@..@.@@@.@@.@@@.
@@@@@.@..@.@@@@@@...@@@@..@@@@@.@...@@@@@.@.@@.@@@..@@@@@@@.@@@...@@.@@@.@@@.@@@@@@@@@@..@@.@.@@@.@@@@.@@@.@@@.@..@@@.@@@.@@@..@@@@@.@@@..@@
.@@@.@.@@@.@@.@@@@.@.@.@@.@@@@@@@@@@@.@@@@..@@.@@@@@@.@..@@@.@@@@@@@.@@.@...@@.@.@@@@@.@..@..@@@@..@..@@@@@@@@@..@.@@.@..@@..@@@..@@@.@@.@@.
@@@.@@..@@@@@.@@@.@@@....@@.@@@@.@..@@@..@@.@@@@@..@@@@@..@.@@@@.....@@@..@@@.@.@..@...@@@@@@@@..@@@.@.@@...@@.@...@@@@@@@@.@@@.@@@.@.@.@@@@
@@.@@..@@@@.@..@.@@@@.@@@..@@.@..@.@@@@....@@@.@..@@@@...@.@@.@@@@@@@.@.@.@@@@@.@@@..@@...@@@@@...@@@@@@@.@.@@.@@@.@.@@.@@@@@@.@.@@.@.@.@@@@
@.@@@.@@..@@..@@@@.@@.@@@@@@@@@@@.@.@@..@@@.@@..@@.@@@@.@..@@@@@...@@..@@.@.@.@.@@@@@@.@.@@........@@@.@@.@.@@@@.@.@...@@@@....@@.@@@@.@@.@@
.@@.@..@.@@@@@@@.@.@@@@.@@@@@@.@@@@@.@@@@.@@@..@.@@@..@@@@.@@@@@.@.@.@@@@@.@@@@@..@@@@@@@@@.@@..@@@@.@@@@..@@.@@.@@@@@@...@@@@@.@...@@@@@@@.
@@.@.@@@.@..@.@@.@.@@..@.@.@@@@..@@.@@......@.@@.@@@@@@@@..@@@@.@.@.@@@@@.@@@.@@@.@@.@@@...@....@....@@@@@@....@.@@@@@.@@..@@...@@@@@@..@@.@
@.@@.@@@@...@@@.@@.@.@.@@.@@.@@@@..@@@@.@@@.@@@@@@@@.@.@@@@@@@@@@@@@@.@.@@@.@@.@@.@@.@@@@@@@.@@@@...@@@.@@...@@@@@@.@.@.@.@@.@@@@.@@@.@.@@@@
@@.@.@@.@..@.@@..@..@@@@.@@@@@.@@.@.@@@.@@@.@@..@@@@...@@@@.@@..@.@@.@@@@.@@@.@@@..@@.@.@@.@..@@....@.@@@.@@@@@@.@@.@@@.@@@..@.@.@@...@@@@..
.@@@..@@@..@.@.@@@@@.@..@@@..@@@.@@@@@.@.@..@@...@.@@@@.@@@@@@@@@.@@@..@@@@@@@@@@@@.@@@@..@@@..@..@@@@@@@@..@@@@@..@@..@@..@@@@..@@@@.@@.@@.
@@.@....@@@@@@@@..@.@@@@@@@.@@.@@@@..@@@@.@@..@..@@.@@@@..@@@@..@@...@@@@@.@@@@@@@@@..@@@@@.@@@.@@@.@..@@.@.....@@@@@.@@@@@.@@@.@@.@@@@@@@@.
.@@@.@.@..@@.@@...@.@.@.@.@.@@@@@@.@@@@@.@@@.....@@@@.@.@..@@@.@@@@@@@@.@@@@@@..@.@..@@@.@@@@@..@@@@@...@@@@@.@@@.@...@@..@@@@@@@@@@.@@@.@.@
@..@@@@..@@..@.@@..@@@@@@@@@.@.@@.@@.@@@@@.@@@@@@@@@..@@.@@@@@@.@@@@@@..@@@.@..@@@@@@@@...@@@..@@..@@@@.@.@@@@@@....@....@@@...@@.@@@@@@@@.@
@@@.@@@@@@.@@@.@@.@.@@.@.@..@@@@..@@@@..@@@.@.@.@@@@@@.@.@.@@@@.@...@.@@@.@.@@@@.@@.@@@@@@.@@@.@@.@@@@.@@.@@@@@@@@@@....@@.@@.@.@@.@@@@@@@..
@@.@@.@@@....@@.@@.@@@@@@..@@@..@@@...@..@@@@@..@.@.@.@@@@@@@.@@.@@@.@@..@@@@.@..@@@.@@@@@.@.....@..@@@@@.@..@@.@@..@..@@@..@@@@@@@...@@@@@@
@@@....@@@@@@@.@@@@@@@@@...@@.@..@.@@@@@..@..@@@@.@@@@@@.@@.@.@.@.@.@@@@.@@.@.@@@@@.@@@..@@@....@..@.@.@@.@.@.....@@@@@.@@@@.@.@@@@.@.@.@...
@@@.@.@@.@@@@....@@@@.....@.@@@..@@.@.@.@...@@@@.@@@@@@@.@@@@@.@..@.@.@.@@@.@@@@@..@@@@@.@@.@.@.@.@.@@..@.@.@@@@@@@..@...@..@@.@@@@@...@.@@@
@@@@@@@@.@@@@@@@.@@@@@@@@@@@@.@@@@@@.@..@.@.@@..@@.@@.....@@@.@.@@@.@.@@.@..@@@.@.@@.@@@@..@@.@@@....@@@@.@@..@@@.@@@@@@@.@@@@...@@@@...@.@@
.@@@@@@@@@.@@@@@@@..@@@@@@@@.@@@@@@@.@@@@@@@...@@@.@@@.@@.@@@.@..@@@..@@@.@..@@@@@@.@@@..@@@@@.@@@@@@@@.@@..@@@@@.@@@.@.@.@@@....@.@..@..@@@
@@...@@@@@..@..@@.@@..@@.@@..@@.@.@@@@@@.@@@@.@@@...@@..@@@@@@@@@@@..@@@.@@@@..@@..@@@@@@@@.@@.@.@@..@@@@@@.@@..@@.@.@@@@@..@@@@@@..@@..@@.@
@.@@@@@.@.@@@@@.@@.....@@@.@.@@@.@@@..@@@@.....@.@..@@@...@..@@.@@..@@@....@@.@.@@@@@@@@@@@@@@@..@@.@..@.@@@@@@@.@@..@.@.@@@@@@@@@@@.@@@@.@.
...@.@.@@@@@@.@@@..@@..@@@...@@..@.@..@@@@@@@@@.@@..@@..@@@@@.@.@@.@@@@@@@.@@@@@@@@.@..@.@..@@@@@@.@@@@@@.@.@@.@..@@@.@@@@@@@@@@@@@@@@.@@@@@
.@@@..@@.@..@@@..@..@@@@..@..@@@@@@@@@@@@@@.@@@.@@@@.@@@@@.@@@....@.@@@@.@.@@@@.@.@.@.@@.@@@@.@@..@..@@@@@@...@@..@.@..@@@@.@.@@@@..@..@@@@.
@@..@..@..@@@@@.@@@....@@.@..@.@.@...@.@@.@@.@@@.@@.@@@@...@@..@@@.@@@@@@@@..@@@.@@@@@@.@@.@@.@@@@@@@.@@@@@.@@...@@@@@..@@@@@@@.@@@@...@@@@.
.@@.@@..@@@@@@..@@@@@@@@@..@...@.@@..@.@....@.@@@@.@@@....@..@...@@@@@.@..@.@.@@@.@@@@@..@@.@@@@@...@..@.@@...@@.@@@@@@@@.@@.@@@@.@.@..@....
..@@.@..@@@.@@.@.@@..@.@@..@...@..@@.@@@@@@@@@@@@.@.....@.@@@.@@@@@...@@.@@@.@.@@@@@@.@@.@......@@.@@@..@....@@@@..@..@...@.@@@.@....@@@@@@.
@@@@.@@.@.@@...@@.@..@@@@.@@...@.@@@@@.@@@..@.@.@....@@@@.@@@@@.@@@@@@@@@..@@@.@.@..@@.@@@@@@.@.@.@.@.@.@.@@.@@@.@@@@@@.@@.@.@@.@@...@@@@.@@
@@@@.@.@.@@@.@@..@.@@@.@@..@@@@.@.@@@@@@.@..@.@.@...@@.@@@.@.@@@@@@.@@.@.@.@.@@@@.@@@....@@@@@.@@.@@@@@.@@@@.@@@@@..@.@..@.@@@@..@@@..@@@.@@
...@.@.@@.@@.@@.@@@.@@@..@@@@@@@@@.@@@@@@@@..@...@..@@..@.@@@@..@@@@@@.@@@@@@@@@@@@...@@.@..@@@...@..@@@@..@..@@@@@@@@..@.@@@.@@@.@@@@@@@@@@
@.@.@@@.@@.@.@@@@@.@@@@@@@@@@@..@.@@@@@.@.@.@@@@@@@@..@.@.@@...@@.@@.@@.@@@.@@@@@.@@@.@.@@.@..@.@@@@.@@...@.@.@@.@..@....@..@@@@@@.@@.@@@@@@
..@.@@.@@@.@@..@@.@@.@@..@@.@@@@@@.@@...@@..@@@@...@.@@@.@@@@@@@@@...@@@.@@@@@...@@.@@..@@..@..@.@.@.@@@@.@@.@..@@@@@@..@@@@@@@@@@@@@@@@@@@@
.@@.@@.@...@@....@@.@.@@..@.@.@@.@@@@..@@@@@@...@@@@@.@....@@.@..@@@..@@.@....@@.@@@.@....@@@.@.@@@@.@..@.@.@@@@.@@...@.@.@@@@....@@.@@.@.@@
...@@@@.@@@@.@@@.@...@..@@.@@@@.@@@@@..@.@@@@@@@....@....@.....@.@@.@.@@@@@.@@..@@@...@@@@.@@..@@..@.@@.@.@@.@.@@.@..@@@@@.@..@@.@@@.@@@@@@@
@@.@@@..@@@.@@@..@@@.@..@@@@@@.@@@@.@@@@@@..@.@.@.@@..@@@@.@@@.@@.@@@@.@@@@@@@..@@@@@@@@..@...@@@@@@.@@@....@@@@.@@@@@.@@@.@@@@@@@@.@@...@@@
..@.@@@@..@@....@@@.@@.....@@@@@@@@.@..@.@..@@...@.@..@@@.@@@.@...@@...@@@@.@.@@.@@@...@..@@@.@..@.@@@@@.@@...@@@..@..@@@..@@.@@@@@@..@@@@@@
.@...@.@@..@@@.@.@@.@@...@.@@@@.@@@@@@..@@.@@@@....@..@.@@.@@.@@.@@@.@.@@@@.@.@@..@@@@@..@.@@.@.@@.@@@@...@@...@.@.@@@.@@@.@@.@@@@@@@.@@@@@.
@@..@@@@@.@...@..@..@@@..@@@.@@@@..@.@@.@@@@.@@.@@@@...@..@@@@@@@@@@.@@@@@@.....@@....@@...@@@@@..@@@.@@@@@@@@.@@@...@.@@.@@..@.@..@.@@@@@@@
.@..@@..@...@@.@@@.@.@..@@..@.@.@.@..@@@@@@..@..@..@@@@@@.@@.....@.@@@@@@@.@.@.@@.@@@@...@@@@@@.@.@@.@@@@@.@..@@.@.@@@@@@@@@@@@..@@@@.@.@.@.
@...@@@@@...@@@@@@.@@.@...@.@@@@@@@@@@..@.@@@..@@.@@@..@@@@@@..@@@@@.@@..@@@@@@@@.@@@@@@@.@.@@@@.@@@@@@@...@@@@@@.@.@.@@@@..@@..@.@.@@@@@@.@
.@..@@.@@.@@@.@@.@@...@@@.@..@.@@.@@@..@@..@@@.@..@@@@@.@.@@..@.@..@...@...@...@@.@.@.@.@@.@@.@@.@@@@..@@@..@@.@@.....@@@@.@...@@.@...@.@@..
@@.@@.@@.@@@@@@@.@@.@..@@@@@@@.@...@.@@@..@@..@@.@@@@..@@@@@@.@@@@@.@@@@@@@.@.@.@.@.@.@.@.@@@@@@@..@@@.@@@.@@.@.@@@..@@@.@@@.@@@@.@@@@.@.@..
@@.@..@@@..@..@.@@@.@@@@@@.@.@@@@@@@@@..@@.@@@@.@.@.@@.@@.@@@@@@..@...@.@@@@@@@@@@@@.......@@@..@...@@@@@@@..@.@@@@@@@@@....@@@@@@@@@@.@@...
..@.@@@.@@..@@...@.@@@@...@.@@@@..@@@.@..@.@...@@@.@@.@@@@@.@.@@.@@@.@@.@@@@@.@@@.@@.@@@..@.@..@@@@@@@..@@@@@...@....@.@@.@@@..@@@@.@@.@@@@@
@@@.@.@.@@@@@@@@@@@...@..@@@@...@@@@@.@...@@@@@@.@@@..@@@@..@@@@@@@@@@@@@@@@.@@@..@@.@@@@...@..@......@.....@@@.@@@@@@@@@.@@@..@@@@@.@@@.@.@
@.@.@@.@@.@.@..@.@@.@@@@@..@..@@@@@@.@@@@.@@@@@.@@@@@@..@@@..@@@@@@.@.@@....@..@@@.@@@..@@@@...@@.@@@@@@@@.@@.@.@.@.@@.@.@.@.@@@@@@@..@@@..@
@@@@@@@..@.@@@.@@.@..@@....@.@@.@@.@@@.....@@@@@@@.@@.@.@@..@@@@@@@...@...@.@@@@@..@@@@@@.@@@@.@@...@@@...@@@@@@.@@@@.@.@@.@....@@@.@@@@@...
@....@@.@.@.@...@@@..@.@@@.@@@@@.@@@.@...@@.@@.@@..@.@....@.@@.@.@.@.@.@@.@@@@.@@.@@..@@@@@@@@@..@.@@@.@@.@.@@@@@@@@@@@@.@.@...@..@.@@@..@@@
.@@.@@....@@@.@@@..@.@.@..@.@@..@..@@.@@..@.@@@@@@.@@.@@@@@.@...@@@@@.....@@@....@.@@.@@@@@@.@@@@...@@.@@.@@.@@@@@@@@@.@@@@...@@.@.@@.@@@.@@
..@@@.@@@.@@@..@@...@@@@@@@@@@.@.@@@@@...@@.@@@@@.@@@..@.@...@@.@@.@@.@@.@@@@@.@.@@@..@@@..@@.@.@..@@@..@@@@.@@@@@@...@@.@@.@.@..@@.@@@.@@@.
.@@@.@@@@@@.@@@@@@.@@.@..@.@@@..@@.@@@@.@@@.....@@.@@.@.@.@@@.@@..@@@@@@.@@.@@...@.@@@@@@@.@@@..@.@@..@@@@..@.@@@.@@@@@@@@@.@@@@.@@@@.@@@@@.
@@.@@@.@@@@.@@.@@@@.@@@..@@@@@@@.@...@@.@@..@@@@@.@@@@@@.@...@@.@@.@@@@@.@@@.@@@@@@..@.@@@@@@@@@.@@@.@@.@.@.@@@.....@..@@.@@.@@...@.@..@..@@
.@@...@@@@.@@.@@@@@@@.....@@@@@@.@.@.@.@@@@@@@@...@.@.@.@@.@@.@.@.@@.@@@@.@@.@.@@@@@..@@@@...@@@@@.@@@@@.@..@@@.@@@@@..@@@@@@.@@@..@.@@...@.
@@@@@@@@@.@@@@@.@@@@..@.@@@@@@@....@@@@......@.@.@.@@@.@.@.@@@.@.@@.@@.@@@@.@@..@..@@@@@@.@@@.@@@@@@@@@@@@..@@@.@@...@..@.@.@.@..@@.@@.@@.@@
@@....@@@...@@@@..@.@.@.@@@...@@@.....@@......@.@@.@@@..@@@@@@.@@...@.@@@@@@@@.@....@@..@...@.@@...@@@@@@..@@.@@.@@@.@.@@.@.@.@....@..@@.@@.
@.@...@@@..@@@@@@@@...@...@@@@.@@@@...@..@.@.@@.@@@@@.@@@@@.@@.@@.@..@@.@@..@@....@@.@@@@@.@@@@@@@..@@@@@..@.@@.@@@.@@.....@@@@.@.@.@@.@@@@@
@@@@.@@..@.@.@....@@@@.@@.@@...@@..@@@@@@.@@.@..@@@@@.@@@..@@@.@@@..@@@@@@..@@..@@...@@@..@@@.@@.@@..@@.@@@@....@......@.@@@.@@@@@.@@.@@..@@
@@@@@.@@.@@@@.@..@@..@...@@@@.@@..@@@@@.@@.@@@@@.......@@..@@@@@@@..@.@.@@.@@@@@@@.....@.@@@.@@@@@.@...@@.@@@@@.@@@.@@@@@@@.@@@.@...@.@.@...
.@@..@@.@@..@@@.@@..@@.@@@.@.@.@@@..@..@@@.@@@@@.@.@.@.@.@.@@@..@@..@@.@...@@@..@...@@@.@@@@.@@@@@...@@@..@.@@.@.@.@@.@@@@@@.@@@.@.@@.@.@.@@
.@@...@@....@@@@@@.@....@@@@@.@.@.@@.@@@@.@.@@@@@.@@@@@@@@....@@@.@.@@...@@@@@.@@@@@@.@..@@.@@.@@@@@@@@..@@.@.@@@..@@@@@@@@.@@..@@@.@@@.@@.@
.@.@@@.@@@.@.@@...@..@@@@@@...@@@@..@@@@@@@@.@.@@.@@@.@.@@@@..@.@@.@@@@@.@@@@@.@@@@..@@@@@@@@.@@.@@@.@..@@@@@.@@..@@..@.@@@@.@..@.@..@@.....
...@@..@@.@@@.@.@@@@@@@@@..@@@@@@..@.@@@@......@...@.@...@.@@@.@@....@@.....@@.@@..@..@@@@...@..@@..@@..@@.@.@@@.@.@.@@.@.@@.@..@@..@@..@@@@
.@@@@@@@.@.@@@@@@@@.@@@@@@..@@....@.@@@@@...@@@@@.@.@.@@..@@@@@..@@@@@@@.@@.@@.@@@...@@.@.@@@@.@@@@@.....@..@.@@.@@.@.@..@@@.@.@.@..@@..@@@.
@@@@@@@@..@@.@@.@.@@@@@@.@@.@@@@@.@...@@@@...@.....@@@....@@.@@@@@@@..@@@.@@@@@....@@..@@.@@@@.@@.@@@@@@@.@...@@.@@@.@.@@@@@@.@...@...@@.@@.
@@.@.@@@..@@@.@.@@.@@@.@...@@..@@@.@.@.@@@.@.@...@@.@@@@@@@.@@.@@@@@..@@@@.@@@.@@@.@@@@@@@..@.@@.@@.@..@@@@@.@..@.@..@@@....@..@..@@@@.@@..@
@.@@@.@@@.@...@@@.@@@@@@@.@@@.@...@.@@@@...@@@@@.@@@@@@@@@@..@@@@@.@@@@.@@@.@@.@@.@..@@.@@@@@.@@@.@@@@@.@@.@@@.@.@.@.@.@.@@@@...@..@@@@@..@@
...@@@@@.@.@.@@@@......@..@.@@@@@@@.@@@@@@.@@@.@..@@@..@.@@@.@.@@@@@@@.@.@@@@..@@.@@@@@@@@@@..@@@@@@@@..@..@..@@@@...@@@..@..@.@@.@@.@.@.@@.
@...@.@@@.@@.@@..@@.@@...@@@.@.@@.@@@@.@..@@@@@@@@@.@.@@.@@@@@@.@@.@.@@..@@@..@@@@..@@....@.@@@.@@@..@@@.@..@@@@@@@@@@.@.@@@.@....@@@@.@@@.@
@@@.@.@@@@@..@.@.@.@@.@..@@...@@@@..@@.@....@@.@.@@@@.@@.@@@.@@.@.@@.@.@.@.@@..@@..@@@@@@@@@.@@@@@@.@@@@@..@@.@@.@@@.@@.@.@@@@.@..@@.@@.....
.....@@@@@@..@@..@....@@@@@@@..@@@@..@.@.@.@@.@....@@@@@.@@...@..@@.@.@..@@@..@.@@@@...@@@.@@@@@@@@@@@@.@.@@@.@.@@@..@@@@.@.@@.@@@@....@@@@.
....@@.@.@.@@@..@@@.@@@@@@@@@.@..@.@.@@@.@...@@@@.@@.@.@@.@..@..@@@@@@@...@@@...@.@@.@@@@@@@..@@@@@@@.@@.@@@@@@.@....@.@@.@.@@.@@@@.@@@@...@
.@@@.@@@@@@..@.@@@@.@@.@.@@@.@@@@@@@@.@@@@@@@@@@@.@@..@@@@@...@@@@@@@@@.@@@@@@@.@..@@@@@.@@@@@@@@@@@....@@@.@@@.@@@@@@.@@@.@@@.....@@@.@@@.@
.....@@@@.@@.@..@@@@@@@@.@@@@.@@@@..@@@@.@@@..@.@@@.@@.@.@@.@@@@..@@@..@@@@@@...@@@.@..@@...@@@.@@@@@.@@..@..@.@@@@@.@@.@@.@..@....@@.@..@.@
.@.@.@@.@@@.@@.@.@@@@@......@@@....@...@.@@@@..@@@..@.@.@@@.@.@@.@@@.@..@.@@@.@@...@.@@.@.@.@@@@@@..@@@@@@@.@@.@@@.@.@..@@@@..@@@.@@.@..@.@.
@.@.@@@@.@.....@@..@.@@@.@.@..@@@.@.@..@.@@@@@@@.@@@@@..@@..@@@@@.@@...@@.@@@.@@.@.@@@@@@@@@@@@...@@@.@@@@@.@@@@@@.@@.@@@@@@..@.@@@...@@@@..
@@@@@.@.@.@.@@@@@@@.@.@@@@..@@@@.@@.@@...@@.@@...@@@.@@.@.@@@@@.@@@@@@@..@@@@@@..@@.@@.@.@@.@.@@@@@@@@.@@@@...@@..@@@.@..@..@@.@..@@@..@@@@.
.@.@.@.@@@@@@@@@.@@.@@.@@@.@@@@@..@.@..@@@.@@@..@@.@@.@@@....@@@@@....@@@@@.@@@@@@@@.@@.@..@@.@...@.@.@.@@..@@.@.@.@@@.@@.@@@@@..@@@.@@@@@..
@@@.@@.@@@.@@@@@..@@@@.@@@.@@@@@.@@..@@.@.@..@@.@@.@@.@@..@@@@@@.@@@@@.@.@.@..@@@.@@@....@@.@@..@@@@@@@@@@.@.@@@@@@...@.@@..@@@@..@@@@.@.@@@
.@@@..@@@.@.@@@@@@.@.@@@@.@@@@@@.@@@@@.@@@@@@.@@@@.@@.@@@@@@@@@@@@@@@@@@@.@@@..@@@@@@..@..@@.@@@@@@@..@....@@..@.@@.@@.@@..@@@.@.@@..@@..@@.
@@@.@.@@@@.@@@@@@.@@.@.@@..@@@..@@@..@.@.@.@@@@@@@@@@@@..@@@@@@@@@@@.@@@@@@..@.@@@@....@@@@@@...@@.@@@.@.@@@@.@.@.@@.@@@@@....@@@@..@@.@@@@@
.@@@@@@@@@.@.@@.@.@.@@..@@@.@..@@@.@@@@@.@@@..@@@..@@@@@@@@@@@@.@@@.@@@@@@...@@.@@...@@@@.@....@..@@..@@.@@@.@@@.@..@.@@@@.@.@@@@.@....@@@@@
@.@@.@@@@@.@@.@@@@@@@@@@..@@@@@@@@..@.@..@@@@.@.@.@@@@@@.@@@@@..@.@@@..@@@@.@@.@.@@@@.@.@@@@@@@@.@@@.@@@@@.@@@...@@@@....@.@@.@.@...@..@.@@@
..@@...@@@@@@@.@.@@..@@@@@@@....@@.@@..@..@@@.@..@@.@.@@@@@@@@@@...@...@@@@@@@.@.@@@@@@.@....@@@@......@@@.@@...@@@@@@..@@@@@@@@@@.@@@@@@@..
@@.@@..@@@@@@@@.@.@@.@@@.@.@@@@@@@.@@@@@@@.@@.@..@@@.@...@.@@@@...@..@@...@@@@@@.@@@@@.@@@..@@@@.@@@@@@...@@@.@.@..@..@@@@@.@.@.@.@@..@@@...
@@.@@@@.@.@.@@.@.@.@...@@@..@..@@@@@.@...@@@@.@.@@.@@..@@@..@@...@@@..@@@..@@@.@@.@.@.@.@.@@@@@..@@@@..@@@@@@..@@@@@@@@@@.@.@..@@@.@@@..@.@.
...@@@@@@@@@@@.@..@@...@@@@@@@@.@@@.@@@.@.@@@@.@@...@.@@..@@@@@..@.@@@..@.@@@@@.@..@@.@@@@@@@.@@@@@@@..@@@@.@...@.@@@@@@..@.@@@@@@@.@..@.@@.
..@@.@@@.@.@.@@@.@@.@.@.@@@.@@@@@@@.@@..@..@@@@@@@@.@@.@@@..@@..@@@@@.@@@@.@.@.@@@..@..@@...@...@@@@.....@@@.@.@.@..@.@@@@@@@@@@...@..@@@@@@
@@...@@@@@@@@.@@@@.@.....@@@@@@@@.@@...@@@@@.@@@..@....@@....@.@@.@@@.@.@@@@@@..@...@..@@.@@@@@@@@@@@@@@...@@@@@@.@@@@@@@.@@.@.@@@.@@@@.@@@@
@@@@...@@@@.@@.@...@@.@@@@..@@.@@.@@@@.@.@@..@@.@.@.@.@.@@@@....@..@@@@.@@@@@@@@@@@...@@.@.@.@@@@@@.....@@@@@@.@@@@@@.@.@..@@@@@.@...@@..@@@
@..@.@@@...@@@@.@@@@@@.@@@.@.@@@..@...@.@@@@@.@.@@@@@@@@@@..@@@@..@@@.@@@@@@@@@@@@@@.@@@@@@@@@@@@..@@.@...@@.@@@..@@@@.@@@@@...@.@@@.@@..@@.
.@..@@..@..@@@@.@.@@.@@@@@.@@...@@@.@..@@@@@@@@..@..@@@@@@@.@@@@@@@@@@@.@@@@@@.@@..@@@@.@.@@.@@..@.@@@@.@@@.@@@@...@@@.@.@@@....@@@.@.@@@@@@
@@@@.@.@.@@@@@@@@.@@@@@.@@...@@@@@.@@.@@...@@@@@@..@@@@@@@.@..@...@@@.@.@.@@@...@@@.@..@@.@@@@...@@@@@..@@..@@@.@@@.@.@.@@@@@@@@.@.@@@@@@@..
.@@..@@..@@@@@@@@@@.@.@@@..@@@@@..@@.@@.@.@.@.@@@@.@@@@@@......@.@@@.@..@@....@.@.@@@@..@.@.@@@@@@@..@@@@..@@@@@.@@..@@.@.@@@.@..@.@@@@...@@
.@.@@.@@@@@....@@@@...@@@@@.@@@.@.@@@@@@@...@.@@@@@@.@@@@@@.@@@@@.@..@.@@.@@..@.@...@@@.@..@@@..@..@.@...@@......@.@.@@@@@@..@@@@@@@.@@..@.@
.@@.@@..@@@.....@.@@..@.@@@@.@.@@@@@.@@@@...@@@@.@.@...@.@@.@@.@......@.@@.@.@@..@@..@.@@@@.@@@.@..@.@@@@.@@@@.@@@@@@@@@.@@.@@.@@@@@@@@@@@.@
@@@@.@@.@@@@.@@@..@@@@@@@@.@@@.@@@@@@@@@@....@@.@.@@.@@.@.@.@@@@.@@.@.@@@@..@@.@....@@@@@.@@.@@.@@.@.@@@@@@.@@@@@@@@..@.@...@@..@@@@..@@@@@@
@.@.@..@@.@.@@@@.@@@.@@.@@...@@@@.@@.@.@@..@@..@@.@@.@.@.@@@@.@@.@..@@@@@@.....@@@.@.@@@@@@.@@@.@.@..@.@@@.@....@@@@@.@@@@.@@.@@@.@....@.@@.
@@.@.@@@.@@@.@@.@.@@@@@@@.@@.@@.@@.@.@.@..@@@@@@.@@@.@.@@@.@...@@@@@.@.@@.@.@...@@@@.@@.@@.@.....@.@@....@@.@..@@@@@@@@@.@.@@@@....@@@@.@.@@
@@@@@.@.@.@..@.....@@@@@@.@.@..@.@.@@@..@@@@@@@@@@.@@.@@..@.@@@@@.@@@@@@@@@@..@@.@@@@.@@.@@.@@@.@@.@@@.@@@@.@@@.@@@.@.@@@@..@@@.@.@@@.@..@@@
..@..@@@@@@@@....@@@...@@@@..@@...@@.@@@@@@....@.@@@@@@@..@@@@..@@@@@@.@@@.@.@@.@@@@@@@@@@...@.@.@@...@.@@@..@..@.@.@@@@@.@@.@@.@@....@@@.@@
@@.@.@.@@@@@@..@@.@.@@.@@.@@@..@@@@@@@@.@.@@@@@@.@@.@@...@...@@..@..@@@@...@.@@@@.@@@@@.@@.@@@@@..@.@.@.@@.@@@@@.@@@.@@.@.@.@..@..@@.@@..@@@
@@@@.@@@@..@.@@@@@@@@.@.@..@..@.@...@.@@@@@@@@.@@..@@@@@.@@@@.@...@.@.@@@@..@.@@@.@@@.@@..@@@@@..@@@@..@@@@@@@...@..@.@.@@.@@.@@.@@...@@@..@
@@@.@@@@@@@@@.@@@@@.@@@@@@@@@@.@@@@.@@.@....@.@.@.@@@.@..@@.@@.@....@@.@@@...@.@..@.@@@@@.@@@@.@@.@@@@@@.@@@..@.@@..@@@.@@.@@@.@.@.@@@@.@@@@
.@@@@@....@.@@@@@@@@..@.@@.@.@.@.@@.@@@...@.@@@@@@@..@@@.....@@....@@@@@.@@.@..@@@.@@@.@@.@@@@@@@...@.@..@@@@@@@@@@@@@@.@@@@@..@@@@..@@@@.@@
@@@@@@@.@@@@.@@@@.@@.@@@.@..@@.@@@@@.@.@@@@@@.@..@.@.@...@@@..@.@...@.@@.@@@.@@...@@..@...@@@.@.@..@@@.@@@@@@@@@@.@.@..@@.@.@@@@@.@@@..@@@..
@@@.@..@@@@@...@..@@@.@@@@.@@.@.@@@@@@..@@.@.@.@@.@@@@@@.@...@@@..@.@@@.@@@@@.@@@.@@@....@.@@.@.@@@@.@.@@@@.@@..@@@.@.@@.@@..@@@@@..@@@...@@

View File

@@ -7,3 +7,4 @@
#include "day1.cpp" #include "day1.cpp"
#include "day2.cpp" #include "day2.cpp"
#include "day3.cpp" #include "day3.cpp"
#include "day4.cpp"

19
utils.h Normal file
View File

@@ -0,0 +1,19 @@
//
// Created by Grant Horner on 12/4/25.
//
#pragma once
#include <fstream>
#include <sstream>
#include <string_view>
constexpr std::string_view to_string_view(const std::ranges::subrange<const char *> cs) {
return std::string_view{cs.data(), cs.size()};
}
inline std::string read_file(std::string_view path) {
std::ifstream input(path.data());
std::stringstream buffer;
buffer << input.rdbuf();
return buffer.str();
}