From fd8bd06069ff4b461de131f07b72316e7955f37d Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Fri, 19 Jan 2024 09:11:00 +0100 Subject: cleanup --- 2023/src/day21.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/2023/src/day21.cpp b/2023/src/day21.cpp index 21a45f7..88fafec 100644 --- a/2023/src/day21.cpp +++ b/2023/src/day21.cpp @@ -38,6 +38,9 @@ find_neighbours(position pos, const vector& lines) { static const vector movements = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } }; + const auto height = lines.size(); + const auto width = lines[0].size(); + set neighbours; const auto [row, col] = pos; @@ -45,7 +48,7 @@ find_neighbours(position pos, const vector& lines) const auto nrow = row + drow; const auto ncol = col + dcol; - if ( nrow < lines.size() && ncol < lines[0].size() && (lines[nrow][ncol] == '.' || lines[nrow][ncol] == 'S') ) { + if ( nrow < height && ncol < width && lines[nrow][ncol] != '#' ) { neighbours.emplace(nrow, ncol); } } -- cgit v1.3