main
Brett 2024-12-12 12:10:58 -05:00
parent 90bf6ae125
commit 7a91078c9a
2 changed files with 25 additions and 3 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(Advent-Of-Code-2024 VERSION 0.0.11)
project(Advent-Of-Code-2024 VERSION 0.0.12)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

View File

@ -75,6 +75,28 @@ namespace day12
std::cout << std::endl;
}
}
struct region
{
blt::vec2i start, end;
};
void expand(region& region, char prev)
{
for (const auto& v : {blt::vec2i{-1, 0}, blt::vec2i{0, -1}})
{
const auto n_pos = region.start + v;
if (plots[n_pos.y()][n_pos.x()] == prev)
region.start = n_pos;
}
for (const auto& v : {blt::vec2i{1, 0}, blt::vec2i{0, 1}})
{
const auto n_pos = region.end + v;
if (plots[n_pos.y()][n_pos.x()] == prev)
region.end = n_pos;
}
}
}
void run_day12()
@ -188,7 +210,6 @@ void run_day12()
else if ((y_pos && (x_pos && !x_neg) && !y_neg) || (y_pos && (!x_pos && x_neg) && !y_neg))
edges++;
if (x_neg && !x_pos && !y_pos && !y_neg || !x_neg && x_pos && !y_pos && !y_neg)
edges+=2;
if (!x_neg && !x_pos && y_pos && !y_neg || !x_neg && !x_pos && !y_pos && y_neg)
@ -206,5 +227,6 @@ void run_day12()
total2 += edges * area;
}
}
print(perimeters);
BLT_TRACE(total2);
}