Compare commits

...

5 Commits

Author SHA1 Message Date
4b1da89690 refactor utils 2025-12-04 22:12:32 -05:00
9282b3d531 finish day 4 2025-12-04 17:41:43 -05:00
debf18936b finish day 3 2025-12-03 15:32:55 -05:00
05a5bc27ad finish day 2 2025-12-02 17:03:54 -05:00
002c7f6a7e finish day 2 part 1 2025-12-02 13:36:30 -05:00
12 changed files with 811 additions and 28 deletions

0
.clang-tidy Normal file
View File

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
cmake-* cmake-*
day1.dSYM day1.dSYM
build
.idea .idea
.cache

View File

@@ -3,11 +3,10 @@ project(cpp)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexperimental-library") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexperimental-library")
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
add_library(cpp STATIC add_executable(cpp_tests
doctest.h doctest.h
run_tests.cpp run_tests.cpp
day1.cpp) utils.h
)
add_executable(cpp_tests run_tests.cpp)
target_link_libraries(cpp_tests PRIVATE cpp)

View File

@@ -5,11 +5,11 @@
#include <cassert> #include <cassert>
#include <charconv> #include <charconv>
#include <ranges> #include <ranges>
#include <fstream>
#include <sstream>
#include "doctest.h" #include "doctest.h"
#include "utils.h"
namespace day1 {
enum Direction { enum Direction {
L = 'L', L = 'L',
R = 'R', R = 'R',
@@ -27,15 +27,17 @@ Instruction parse_instruction(std::string_view line) {
std::from_chars(&line[1], line.data() + line.size(), amount); std::from_chars(&line[1], line.data() + line.size(), amount);
return Instruction{direction, amount}; return Instruction{direction, amount};
} }
}
template<> template<>
struct std::formatter<Instruction> : std::formatter<string_view> { struct std::formatter<day1::Instruction> : std::formatter<string_view> {
static auto format(const Instruction &i, std::format_context &ctx) { static auto format(const day1::Instruction &i, std::format_context &ctx) {
return std::format_to(ctx.out(), "Instruction[direction: {}, amount: {}]", static_cast<char>(i.direction), return std::format_to(ctx.out(), "Instruction[direction: {}, amount: {}]", static_cast<char>(i.direction),
i.amount); i.amount);
} }
}; };
namespace day1 {
const std::string sample = const std::string sample =
"L68\n" "L68\n"
"L30\n" "L30\n"
@@ -79,9 +81,9 @@ uint32_t solve_first(const std::string &input) {
uint32_t spins = 0; uint32_t spins = 0;
for (const auto instr: for (const auto instr:
std::views::split(input, '\n') std::views::split(std::string_view{input}, '\n')
| std::views::transform([](auto s) { return std::string_view(s); }) | std::views::transform(utils::to_string_view)
| std::views::filter([](const std::string_view s) { return !s.empty(); }) | std::views::filter(utils::non_empty)
| std::views::transform(parse_instruction) | std::views::transform(parse_instruction)
) { ) {
if (spin(value, instr)) { if (spin(value, instr)) {
@@ -93,13 +95,10 @@ uint32_t solve_first(const std::string &input) {
return spins; return spins;
} }
TEST_SUITE_BEGIN("Day 1");
TEST_CASE("puzzle 1") { TEST_CASE("puzzle 1") {
CHECK(solve_first(sample) == 3); CHECK(solve_first(sample) == 3);
std::ifstream input("day1input.txt"); CHECK(solve_first(utils::read_file("day1input.txt")) == 1158);
CHECK(input.is_open());
std::stringstream buffer;
buffer << input.rdbuf();
CHECK(solve_first(buffer.str()) == 1158);
} }
uint32_t solve_second(const std::string &input) { uint32_t solve_second(const std::string &input) {
@@ -107,9 +106,9 @@ uint32_t solve_second(const std::string &input) {
uint32_t spins = 0; uint32_t spins = 0;
for (const auto instr: for (const auto instr:
std::views::split(input, '\n') std::views::split(std::string_view{input}, '\n')
| std::views::transform([](auto s) { return std::string_view(s); }) | std::views::transform(utils::to_string_view)
| std::views::filter([](const std::string_view s) { return !s.empty(); }) | std::views::filter(utils::non_empty)
| std::views::transform(parse_instruction) | std::views::transform(parse_instruction)
) { ) {
spins += spin2(value, instr); spins += spin2(value, instr);
@@ -121,9 +120,8 @@ uint32_t solve_second(const std::string &input) {
TEST_CASE("puzzle 2") { TEST_CASE("puzzle 2") {
CHECK(solve_second(sample) == 6); CHECK(solve_second(sample) == 6);
std::ifstream input("day1input.txt"); CHECK(solve_second(utils::read_file("day1input.txt")) == 6860);
CHECK(input.is_open()); }
std::stringstream buffer;
buffer << input.rdbuf(); TEST_SUITE_END();
CHECK(solve_second(buffer.str()) == 6860);
} }

188
day2.cpp Normal file
View File

@@ -0,0 +1,188 @@
#include <cassert>
#include <charconv>
#include <ranges>
#include <string>
#include <fstream>
#include <sstream>
#include "doctest.h"
#include "utils.h"
namespace day2 {
const std::string sample =
"11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,"
"446443-446449,38593856-38593862,565653-565659,824824821-824824827,"
"2121212118-2121212124";
struct Range {
uint64_t start;
uint64_t end;
};
} // namespace day2
template<>
struct std::formatter<day2::Range> : std::formatter<std::string_view> {
static auto format(const day2::Range &i, std::format_context &ctx) {
return std::format_to(ctx.out(), "Range[start: {}, end: {}]", i.start, i.end);
}
};
namespace day2 {
Range parse_range(std::string_view s) {
std::string_view start;
std::string_view end;
for (size_t i = 0; i < s.size(); i++) {
const char c = s[i];
if (c == '-') {
start = {s.data(), i};
end = {s.data() + i + 1, s.size() - start.size()};
}
}
Range range{};
uint64_t parsed;
std::from_chars(start.data(), start.end(), parsed);
range.start = parsed;
std::from_chars(end.data(), end.end(), parsed);
range.end = parsed;
return range;
}
size_t find_divisor(const uint64_t n) {
for (size_t i = 1;; i++) {
size_t div = n / std::pow(10, i);
if (div == 0) {
return std::pow(10, i / 2);
}
}
assert(0 && "Unreachable");
}
uint64_t count_repetitions(const Range range) {
uint64_t total = 0;
for (uint64_t n = range.start; n <= range.end; n++) {
auto div = find_divisor(n);
auto left = n / div;
auto right = n % div;
if (left == right) total++;
}
return total;
}
uint64_t sum_repetitions(const Range range) {
uint64_t total = 0;
for (uint64_t n = range.start; n <= range.end; n++) {
const auto div = find_divisor(n);
const auto left = n / div;
const auto right = n % div;
if (left == right) total += n;
}
return total;
}
uint64_t solve_first(std::string_view input) {
uint64_t result = 0;
for (const auto range:
std::views::split(input, ',')
| std::views::transform(utils::to_string_view)
| std::views::transform(parse_range)) {
result += sum_repetitions(range);
}
return result;
}
uint64_t sum_repetitions_2(const Range range, std::string &buf) {
uint64_t total = 0;
for (uint64_t n = range.start; n <= range.end; n++) {
std::format_to(std::back_inserter(buf), "{}", n);
size_t size = buf.size();
for (int i = 0; i < size; ++i) {
if (size % i != 0 || size / i == 1) continue;
std::string_view first_partition(buf.data(), i);
bool all_equal = true;
for (int j = i; j < size; j += i) {
std::string_view partition(buf.data() + j, i);
if (partition != first_partition) {
all_equal = false;
break;
}
}
if (all_equal) {
total += n;
break;
}
}
buf.clear();
}
return total;
}
uint64_t solve_second(std::string_view input) {
std::string buf;
buf.reserve(100);
uint64_t result = 0;
for (const auto range:
std::views::split(input, ',')
| std::views::transform(utils::to_string_view)
| std::views::transform(parse_range)) {
result += sum_repetitions_2(range, buf);
buf.clear();
}
return result;
}
TEST_SUITE_BEGIN("Day 2");
TEST_CASE("Can parse input") {
auto range = parse_range("11-22");
CHECK(range.start == 11);
CHECK(range.end == 22);
}
TEST_CASE("Solve first sample") {
CHECK(solve_first(sample) == 1227775554);
}
TEST_CASE("Solve first input") {
CHECK(solve_first(utils::read_file("day2input.txt")) == 21898734247);
}
TEST_CASE("Find divisor works") {
CHECK(find_divisor(11) == 10);
CHECK(find_divisor(1221) == 100);
CHECK(find_divisor(222222) == 1000);
}
TEST_CASE("Count repetition works") {
CHECK(count_repetitions({.start = 11, .end = 22}) == 2);
CHECK(count_repetitions({.start = 1188511880, .end = 1188511890}) == 1);
}
TEST_CASE("sum_repetitions_2") {
std::string buf;
buf.reserve(100);
CHECK(sum_repetitions_2({95, 115}, buf) == 210);
buf.clear();
CHECK(sum_repetitions_2({998, 1012}, buf) == 999 + 1010);
}
TEST_CASE("Solves second sample") {
CHECK(solve_second(sample) == 4174379265);
}
TEST_CASE(
"Solves second input"
* doctest::skip(true)
) {
CHECK(solve_second(utils::read_file("day2input.txt")) == 28915664389);
}
TEST_SUITE_END();
} // namespace day2

1
day2input.txt Normal file
View File

@@ -0,0 +1 @@
655-1102,2949-4331,885300-1098691,1867-2844,20-43,4382100-4484893,781681037-781860439,647601-734894,2-16,180-238,195135887-195258082,47-64,4392-6414,6470-10044,345-600,5353503564-5353567532,124142-198665,1151882036-1151931750,6666551471-6666743820,207368-302426,5457772-5654349,72969293-73018196,71-109,46428150-46507525,15955-26536,65620-107801,1255-1813,427058-455196,333968-391876,482446-514820,45504-61820,36235767-36468253,23249929-23312800,5210718-5346163,648632326-648673051,116-173,752508-837824

68
day3.cpp Normal file
View File

@@ -0,0 +1,68 @@
//
// Created by Grant Horner on 12/3/25.
//
#include <ranges>
#include <string>
#include "doctest.h"
#include "utils.h"
namespace day3 {
const std::string sample = "987654321111111\n"
"811111111111119\n"
"234234234234278\n"
"818181911112111\n";
auto split_into_banks(const std::string_view input) {
return std::views::split(input, '\n')
| std::views::transform(utils::to_string_view)
| std::views::filter(utils::non_empty);
}
uint64_t solve(const std::string_view input, uint8_t num_batteries) {
uint64_t sum = 0;
for (auto split: split_into_banks(input)) {
uint64_t bank = 0;
size_t largest_index = 0;
for (size_t i = num_batteries; i > 0; i--) {
const auto num_reserved = i - 1;
const auto substr_len = split.size() - largest_index - num_reserved;
const auto not_last = split.substr(largest_index, substr_len);
size_t temp_largest_index = 0;
uint8_t largest = 0;
for (size_t j = 0; j < not_last.size(); j++) {
if (const char c = not_last[j]; c > largest) {
largest = c;
temp_largest_index = 1 + j;
}
}
largest_index += temp_largest_index;
bank += (largest - '0') * std::pow(10, i - 1);
}
sum += bank;
}
return sum;
}
TEST_SUITE_BEGIN("Day 3");
TEST_CASE("solve first sample") {
CHECK(solve(sample, 2) == 357);
}
TEST_CASE("solve first puzzle") {
CHECK(solve(utils::read_file("day3input.txt"),2) == 17095);
}
TEST_CASE("solve second sample") {
CHECK(solve(sample, 12) == 3121910778619);
}
TEST_CASE("solve second input") {
CHECK(solve(utils::read_file("day3input.txt"), 12) == 168794698570517);
}
TEST_SUITE_END();
}

200
day3input.txt Normal file
View File

@@ -0,0 +1,200 @@
2232212212212222211221231124224222213132222133122224222123222112324122222122221322222225222342243112
2222312114222314322223142323251122424322142244122212213222222222242526225232262212234353242222112242
3325444446453345434534234244443254434533443354443344424431124344542134454433534353443542455544444483
2334235313232232645234524223233333333323323333233334323332325633143222333322242333132233233132212325
2234311224123424222222224432222333212224412234223312244413252153222112433222334322772215422121224273
4522445145543645454343253542221455532354534564325445322522535254222337733425252243221532745237255133
2214225223121214462323123283942523226421423233325342644222213411423272383842222442422213122912324522
2122242232325524322242212232524425223232232233432221122322233512432222441122422314222122221222212225
8222353391373332335354222456125222358233122233316323355352531234333527222223352436381343533536331244
2127632636444323427265228625582625772229446462233352433587748742382622354425852874557228522772714265
5764566853423796763449339447557566366572334553648326634466376656683936736543746865667784426952852681
2121232232222322211232122232213212117222223222221652221222212242222222222333321322222222222122522223
3311487326434675433324437437335526732665253343574234535363333477334461753847265314545424442324747728
6252536321432743472244167342323675732726575412571775613245775732227775657226312524123527567671676189
7533722333717216436553422342221352632923463174227273634221314835124324462631282462922324654573644336
3334347211322211322233222241233221232124212322322224423224253425525344442212222284312232222324322414
8767635775767537537775596426945666564695551577422716939227657554649562833366674365266155727577774737
7775767466374676353856676436275545371656656638858776373448786645468766554726777677755355577244574383
4124457552243552342355664445373255223422339335535644524442445657442153557545543453354343433643267753
6124333457242323425527522653254242224232423232264274434422411227635523364224422236253335315116127532
3843363244543644643446444336332633352434545244436626634545444448444432343456656564456736353434435763
2422221722221518823422211232528222221322741422521112323225722252542221222152231123242126243222522576
1622233224223242225223226253345331335142347122554523313243535325924223222222332241922222221423233121
4422161223245313242212152356523252352332114532131212331132322223662325121132255222245126112324622222
4233231332312314222233333341133332452443423443134344332243234243444423443533423343333244354382332434
6412258431772524433228362126666441227873942928375972932224772779977239924896932962725678357742792757
2227271234224232322222332222221223242222336232222321222123332221232363322222123232311223225321123324
7589939488935898867996484599788786867736849995938599889798476788896676459989897766888896597487889955
3454654452545325445345241613354242541353364444436354434433222254535434343434244433352454491236544424
3555422223544453332243232524152235232432234321322225424353448233244453333633454744244242322633235544
2124222224441239425244322954112523572245362622825554225282222736532822246252222222625122321847223735
3236336542322621344455252325253252236337264153213264532252332554223524342132622262555624217132225523
2526592122123332422822131141234342452222223213126221224262242336444543224251621223527425633635432422
4627434275335624743842223367643372773416353388754337724725344333445735354575952356357743428124523423
5131323342333323332333223333231343333533322133333351233343323326353222332223323323355332223125436611
3267823353225414622752883222125222822288682231242712212212222312622262222232262239152212766233622742
3233632122333233633333333331713131221283512363322533235333333353253232423232232312332336353232511333
7537335633333332333257451533743636333336344234383233638333825643833324862326234334536343333337341534
7374226635593315434733244453342226646737436272495334563847314623624832636243233334512322529283445263
4332232521223522524213221234143433214242236352238234234145322342235343223263631624558153124433322263
2522212625442322522232213336422222244225234213335226232232544223291312422512225122122152452522284222
3223121222448242222232124324212222232372344252326235832228322247122222322232422122282212222221222334
3532267229665572922222236676865635148363573285411561725352232854345323542463955323228643283411566268
3357562156445382573453552434624343344555753334452344275353435433233343545435554553531442333343545323
4432285342325163234221332435222123365325322323334325472242261325439248524244352229353255664624222332
5431252222458374243642592224346445254352332235374424452555534438625129442442434335415312335582323233
4323424443537342215451244432322222322262445334343422342225131243343242422312542126413331246233333414
4364214533233224324343345333333332333523353333324214315243433333323413413343433343343135333312343333
3223134252331264234231223413332384833323311111472333258232326331233453222123283532162132322222213123
2122322222222332222212412222421222212222335322222123213121232223222355331222241212232223222122212222
2224234336222923229631122212222612332523531322272232233123322223442324123313256323423442722216232512
3333324326462443643324233235432334632354333323332336163232334253342523333223351246225324332353535564
2652435323434322222223325242213225213233122223236242225241342232234132526222345232157223522552124332
3411222222226222221122322113222221223126312216224221122212222122242222222312122212727221212242231221
4456532435443334732561536454334463553353556454575452634335511435653443333455255235435445465545553134
2228332566243332533533252323335332231316214213243333232133434226343943323352214232213322333433335212
3365426738758286223813946783465373375236837736556379353363573387385397747575645375432373453243373298
2374464353232333237353476246233321127232426742236472547323234324246433373336253442412444322493272472
3433823214282232422432246132534272631326662712841823232362422314263262437186423322512121721222764782
2212221325332253132322215232314222142112221124222235222233333213232243132233223322232175233332233222
1322232332221132111122231322312233222432221422243222233423433133225222224321322322323233327224222232
1646353222222366621126365622131123313224423236214524422434321352522352211643433222432424454255232342
3361246654224456345614565445236613412443442534524666655261365666531522166125553226265651516625126789
4324334643744332474343444449444636345744136484654443344354443433464531343444454463434747785437245447
5452122332323323125222212232221332222222222222222231232312182222123242331122112231122421221323232422
2211251211252222622253221332252222212922232222322322221222422124228552222312622122221221222212274322
6312233221334343211331335223232235222532314222232223323423323343132222221133225123323476243233223114
6365746667644366678673776345675677645664653459445634735635562465556549961355736666746565734664645547
3221223222222332212221322122324222122122122211112214222322122122222121222222112112232222231433222122
1422361231254154455327225426522633323223321223545452553224325226628412212635854242361124447216543452
3666233524341323332235392765343263455725455245627253316134426537127422852162423422242634754221114822
3932433363332433232333726333333322334331332636223844223125733237523322343253323322253713213222333332
4493744344343834344443452343336344428436454332433425458644535434483442554494443454624254346454444533
5699934925565955456654646643377577254475687546547848667996565655157229655448156642565884755556349397
2412344544333346124443433363233223333343333344336734136233423334433433343143232333143233365933334343
1629643246222715451822963326475635412213424375224242216415646222713289214241172435222575212224121736
2252522432412549512366312275222222373242325416522265412221721226556221122252235273275426642122427522
1413222233624135145593211616522426244254844452521552272422254536455622433271358325522434313343224463
3224423212432442132244433242415322342232432332224213224242231424233421323324222242444232222443422223
3422233231433314333231233333233333333423333433332331343321233243133333323331342324322433343233423333
4245333537332234633432342332323328332232224343333343334353514454433722242233353641212333285343631332
5223226432542535334272221623443313523443252332624714433827453354551322323276223543323322425214216561
9797352317238959996855458878658559627886527272323796576749782735857222478979158267967842734532637298
2233315472222233225323231342221225322534411322222222252221323222211243442321411412233132323235245223
3242242512222224434221246355113123221214231222336222222262323212273222434232324213712221324222532544
5232232112233212221222742221224212221222222132222221222213222521351152131361223222222221231121122122
2322322121321222222221241222222222222221211222223124142212222222123212322212222122222421122222252222
4334454542453614443324434444464344564545444424444454554444454443434343364344354444434442344253434444
2212322523313311222122522623343141322313342331212442222412224524322223244452231316412252262323322222
2222212272212222122122222522113122242221222222222212222224122222221222122221224121212222212212412221
2262337146893946174873662226535147545374544263382266265526568543452839587616544643126292665282936624
3632252333332333333443223232262335313333233332314333343233345243313243233365363313235323332251334333
3221232222222231322523223221226228231232223121521222423642122221212222322222122223241211231231323322
2221222222211221222321222222321111241222212221223224222111226222222222127221122321122322222222223222
6124144523332424733744135412344413421242123443515845332333352381548533242422427444334537433335322574
7453758454284755866546827436558875877536562985475866626748436685734445624337877296528474836188782753
5725733623574543384332644163741436413538624353353125322413732535252354534676342533233443636764346533
3724543433444425433433334324347463344832345544343464234456334442253444343934444232343544352344734343
6573566365455442255555524262564564545162457584866572865548453564655536755528442528355355335274452555
3222221223313472322312322223112362322312222112321321222323333422212221332242211232332234312422322226
6684364344445364343623423527355342443365534744737476345423442431424363432387333644234536114334313743
3233322323622333233224331231516231133322322232233222222232342523213345323243332215613222522443353132
5233232142321234421331321222222312221211123133132324142229222222223223232222223422232222224362224341
1623812226295322222452341223423224244822222244262222226522254322222354323823234622623342833422134243
8333332232332233233122333321222322323322223212332226112423223216223222223321223122433232322322133323
1445455125545213412322444525223256423451342852266534614222242224134464414322623543351274434232725426
5573546354364544548532342646434444554247464434444334464533335544555447424544744345433465422444335345
4562565676457555226566266835565649635546563647665517725942797526353315545955559436375764268749645898
6575389545666586355556557655258454466366756659655667656556582566555465559455532256575635466765755551
2522372325223285372377443342324824613332232726232122334317271432643232352312841322424762333233395233
2325212222222422242642232311222421214211222221222214422221222242131222122222521362214232321222124221
3443334344363536646652475343315326533663446343345554247337628331336572334445334673738533443665543342
2132212222231122223244212212222212228222233272341222122222242352251212322325222212211922122624222222
9575468865546956387974456933636335313545532835783785683744589494443434344565445464834553577825488995
2232221523232232222252336212562321222122411723311522222422216223221222621222176222222111614122221252
2411324543243436234332382332234214435321523422313323444432433242322423134133444241124142332331234444
3433433334352343225433321342331324334324436434454253433254434433232322423433335424444433233323343334
3223422232335211433544355441333533324324224521343345431633342323623234437234243141342447733332355443
2411332212121252533343422283442212322133324233124822321255297222331282432222722222422225234551324542
1212122312232223236244132211522422335231321321233311413522332233123232243232312123322221522432333223
7334732333343334432153322533242333342334333433542333323344232343333631333134333324341334323332233321
4223522232212222331134221222522114354221215211122143472242233151322215324333435221222111222125242222
3222333222332132352223221213322232222113211132322232323223262222322232231433522222332222122315322222
4241254433142142123222423422312231234332242212342422234142423232314242344322144224343422223212435253
4435124394543415434351654321444434453344533554424428337244554533353443435545332645235353543553624434
4953545494325476235384273555532639985727583622585542734352939855234464949436494654347624427975335752
1232253544413221381621112135437813322644122432322123133243121211252322135345213422232223825116322142
7176762571577351467326138773541464454587645184235842236622256247346688118431458431258687874365414659
2234232222222322322227532122582522122332422321222223222212152215325222223321221223223281421221322272
2425383136529333525526333212772263633723248433642255323553412633172463436577851421236523265744234522
3424262253652335642215242324645354215251762247525283223142532441334534261222436332322215452368293294
3525625641636442423534235631325866434443266454611324526226469346631344363145685421462455233735624345
5276763684237376172166382633667247437378333539246423364394367744953897395676234326742766684349243562
4233422424444222242434315214323442396243233222224442344444422342234344623323212323224426342442427234
2455654832635651757551426372442144653642514347558494583127222312332291665422754344255247559626765126
2423243424113222233244222221234543212222174224434222112321343222222321212333423144422255222222413122
3323333236543227312763323323522323831924221328237333782233235623233343431243535322223335382353122133
2642453233833326882633337743646383422483273534435314347233322527835732448264631373443364128368335834
6321247133126761767527423261476422264542629276752248335262214216629211627473621659671535368222612669
5343777868459585575482665644767666773655757774767864755776477544456869665597555737746565466765544456
1561262334141223245665535412224136232446722652331362425423161246335221246455132554556132262625222555
5725416122222431321214232245422252241221232124234422112421223522241233231222223232253322412111224464
1342634245353479774636277557464349166649866286327455463463636677272756383566156564766367664434525544
2222214123614223121322332318514242112223523113141382142232142142233231421222362222233262322213343743
6232323432322254643333225193233343333423321243245225332132242323632264522322336122232231212351212223
3134444244333433225323244553224323233233323334332322233334131123434334332263343643354324333333333333
5532268321431422223343232322352234537313226334376242424454322432374463252213326577332252837226334641
5454844649566486677668957445459426468556946465673647773845366434343566647393767866654877854729566655
2422261322545145375223322644442555224434132222357432123332514282554322645316424122242235533345325354
3453712694444284286643414431362435383471343775542345353323626357143668234121858535252933816335326432
2692252814322492259236385535955522425425223342262252322174535732822419432644742213257343242222582643
6224333313434321343237423443742234422322332352563424433343233254324214252234443222233353343243333445
4341454432233455223475433475834433424452531334443432434434543434324144237344441424343324333441646255
7434464744476424675745843545587323486545535756479535344455254523223337565676533355416635334549535976
3553356443855549413244624436535286254385433334226234338534135565231251535244343542565554226235635334
6573451149567373447735352333764555854832677437453435454465844374557267983453554498384334844362354649
3222254452422632224342325232542722451421242426521244243425424432222231324222222222222224444132543462
2122421222232412322232411222341132211222815512622251621622322425233342126123321222212233532357222222
2212232521412331133232455327233262332232323333233232141422322434333231222732323462221323232213222211
3232332221511232236313222373234232352363332233522423133221423342323322222133322133333332222243322362
2336422223291359222423422723843312323142222422352222453222313423325226423333532343317321422225321142
4343335344372513234535342343343331535336323543354634443324332253537437441345145433453334416434323352
3237453244334333332544534453434432432453435333343236534453223333433262234443423444431235133845232333
6456227863763242255472623627231646622542245446515545363156162236672662444622442685215534225266296642
2221332422312223552533253124222143223432222123213232331623267323322312232362544423433242224434255212
6223465529466236233843281262333513534533347144636335524465365425322223373826446133535333335936553663
2422522232222332132222436342244222212125223234334411321232322424384243222245362244243432424231222224
2455326555464433825522411753425666565575612655266536636523455355543744564462384354365164425355735543
2222222223222222111222222222212213221233232222222332113222221222262222132221221212122223112222122132
3757772733244484433471354299755673837533632373346333735764325326263332933364634336225349447642767347
6437333932233533335653243853723337632339355633363334344352325433234631533434522225121233842335623366
1522322353333243423526152523222341222216322522631222136252125432232222422232211222322636312253262237
3244925232233442334453242444241423433222233234323483133314262243244121333332323242321254222333333331
2353223342323312327232322421224232123221132271242314335221333242245322142323223222134422332222223313
2232223222152322222221221121232212124133322431112342321232222222321222211232233311232221222232222123
3453545474334436473443566463435375435867524354646246572375445332562455654454447265633425553447415546
8325538754433525383334434495321546255334334349823332443333244294334243537453573399238389554251532513
7656246667563266466285456546456634856666957366663567458366756667648824545698465586644656686567376793
4215351543432113323415311324225123133123142113334411255112542454441323515215512232515424352535536789
1111223223122222222212222222222121222121222222225422222222212322222222233211242234122121222221222213
5678874659337973585843437281459576744742867132948467828423979842756986437335768649266634535646384756
3321432323333214232334221532121112433224263223323333735223333142518214311333551312233337431332222331
3221122322355421122222453222425223221222442312325124432242254223232322354422311511222231212225272322
3326243721153143233313222221442134142337593334337525233226413533524382451233373863723253915332223322
4323922223241324233114233242234372243132523323224232522234672222932332123232522413335233242223326132
4322523121353121333322532434134233233114242224344533323351233542365523264233431435614923234534264343
2413439321538222312223262451523242222223422221322414424312213143162222233225243213124234222242234342
3342122215245575225214522336225122222452225452142422442322242424233553522122474675551126222332423412
2233212232112143223212212231131212212233232223222231322122222122333332123123222222332132432232232322
3123343334341232234231322243134412132113314413424131312441443333224114142441423243344314242144456789
5385554234435342844722553342162686427245123565484553455665282646565214247314425653986444256446243726
1423322322142322343222211212322232222242323233132433232122324221321213111311232212131253212246222322
2251232221222126122123211222231232221222262212221122111222221232222322212212212223221222222222222242
4433211425222435344223312275476734164333243421521257332731712552245523223432413345313534272123232531
5374861454518743534536288564523325333536745576255527655233661778769564756756829149877383953443336824
3313122322343331253323335333343224231126233223221243331333312332333332332332233322123323223253233333
4413524351244212524255443427242452242444414252125243353241535255256425423353123331432285522243215864
4233233624553534233334344223842653442554363333343434314464443234333354472933333443314632434634254324
3553898859594653737688866779538897656477718999867897996545698835748668695853929454638293454775739576
3616433333424364342231322772322273742562435322524343222733733633315231217432253332344435423437477333

151
day4.cpp Normal file
View File

@@ -0,0 +1,151 @@
//
// 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<utils::StringLike T>
std::array<char, 8> get_surrounding(const std::vector<T> &lines, const size_t x, const 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(utils::to_string_view)
| std::views::filter(utils::non_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) {
if (lines[y][x] != '@') 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<utils::StringLike 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(utils::non_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(utils::read_file("day4input.txt")) == 1626);
}
TEST_CASE("solves second sample") {
CHECK(solve_second(sample) == 43);
}
TEST_CASE("solves second puzzle") {
CHECK(solve_second(utils::read_file("day4input.txt")) == 9173);
}
TEST_SUITE_END();
}

140
day4input.txt Normal file
View File

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

View File

@@ -5,3 +5,6 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h" #include "doctest.h"
#include "day1.cpp" #include "day1.cpp"
#include "day2.cpp"
#include "day3.cpp"
#include "day4.cpp"

33
utils.h Normal file
View File

@@ -0,0 +1,33 @@
//
// Created by Grant Horner on 12/4/25.
//
#pragma once
#include <fstream>
#include <sstream>
#include <string_view>
namespace utils {
template<typename T>
concept StringLike = requires(const T &t)
{
{ std::string_view{t} } -> std::convertible_to<std::string_view>;
{ t.size() } -> std::convertible_to<size_t>;
};
constexpr std::string_view to_string_view(const std::ranges::subrange<const char *>& cs) {
return std::string_view{cs.data(), cs.size()};
}
constexpr bool non_empty(const std::string_view sv) {
return !sv.empty();
}
inline std::string read_file(std::string_view path) {
std::ifstream input(path.data());
std::stringstream buffer;
buffer << input.rdbuf();
return buffer.str();
}
}