From 4da8dfe04e76a836e64154927c44e5a3d1dea1d2 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 12 Dec 2024 22:37:43 -0500 Subject: [PATCH] silly --- .idea/editor.xml | 717 ++++++++++++++++++++++++++-------------- CMakeLists.txt | 2 +- problems/day12/example1 | 2 +- src/day12.cpp | 76 ++++- 4 files changed, 545 insertions(+), 252 deletions(-) diff --git a/.idea/editor.xml b/.idea/editor.xml index 822bae1..b0d69ef 100644 --- a/.idea/editor.xml +++ b/.idea/editor.xml @@ -1,244 +1,483 @@ - \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d03c80..df1ca94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(Advent-Of-Code-2024 VERSION 0.0.12) +project(Advent-Of-Code-2024 VERSION 0.0.13) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/problems/day12/example1 b/problems/day12/example1 index cc5f968..b41163a 100644 --- a/problems/day12/example1 +++ b/problems/day12/example1 @@ -1,4 +1,4 @@ AAAA BBCD BBCC -EEEC \ No newline at end of file +EEEC diff --git a/src/day12.cpp b/src/day12.cpp index a8df1ba..e843777 100644 --- a/src/day12.cpp +++ b/src/day12.cpp @@ -96,7 +96,6 @@ namespace day12 region.end = n_pos; } } - } void run_day12() @@ -173,6 +172,7 @@ void run_day12() continue; bool x_pos = false, x_neg = false, y_pos = false, y_neg = false; + bool x_y_pos = false, x_y_neg = false, x_pos_y_neg = false, x_neg_y_pos = false; { const auto v = get(plots, pos.x() + 1, pos.y()); @@ -190,6 +190,22 @@ void run_day12() const auto v = get(plots, pos.x(), pos.y() - 1); y_neg = v && v->get() == cur; } + { + const auto v = get(plots, pos.x() + 1, pos.y() + 1); + x_y_pos = v && v->get() != cur; + } + { + const auto v = get(plots, pos.x() - 1, pos.y() - 1); + x_y_neg = v && v->get() != cur; + } + { + const auto v = get(plots, pos.x() + 1, pos.y() - 1); + x_pos_y_neg = v && v->get() != cur; + } + { + const auto v = get(plots, pos.x() - 1, pos.y() + 1); + x_neg_y_pos = v && v->get() != cur; + } if (x_pos) pos_to_check.push({pos.x() + 1, pos.y()}); @@ -201,19 +217,59 @@ void run_day12() pos_to_check.push({pos.x(), pos.y() - 1}); auto b4 = edges; - if ((x_pos && (y_pos && !y_neg) && !x_neg) || (x_pos && (!y_pos && y_neg) && !x_neg)) + if (x_pos && (y_pos && !y_neg)) + { edges++; - else if ((y_neg && (x_pos && !x_neg) && !y_pos) || (y_neg && (!x_pos && x_neg) && !y_pos)) + if (x_y_pos) + edges++; + } + if (x_pos && (!y_pos && y_neg)) + { edges++; - else if ((x_neg && (y_pos && !y_neg) && !x_pos) || (x_neg && (!y_pos && y_neg) && !x_pos)) + // if (x_pos_y_neg) + // edges++; + } + if (y_neg && (x_pos && !x_neg)) + { edges++; - else if ((y_pos && (x_pos && !x_neg) && !y_neg) || (y_pos && (!x_pos && x_neg) && !y_neg)) + // if (x_pos_y_neg) + // edges++; + } + if (y_neg && (!x_pos && x_neg)) + { edges++; + // if (x_y_neg) + // edges++; + } + if (x_neg && (y_pos && !y_neg)) + { + edges++; + // if (x_neg_y_pos) + // edges++; + } + if (x_neg && (!y_pos && y_neg)) + { + edges++; + // if (x_y_neg) + // edges++; + } + if (y_pos && (x_pos && !x_neg)) + { + edges++; + if (x_y_pos) + edges++; + } + if (y_pos && (!x_pos && x_neg)) + { + edges++; + // if (x_neg_y_pos) + // 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) - edges+=2; + 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)) + edges += 2; if (!x_neg && !x_pos && !y_pos && !y_neg) edges += 4; @@ -221,12 +277,10 @@ void run_day12() visited_side.insert(pos); - } BLT_TRACE("For %c do %d edges with %d area", cur, edges, area); total2 += edges * area; } } - print(perimeters); BLT_TRACE(total2); }