diff options
| author | Thomas Schmucker <ts@its1.de> | 2024-01-19 09:11:00 +0100 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2024-01-19 09:11:00 +0100 |
| commit | fd8bd06069ff4b461de131f07b72316e7955f37d (patch) | |
| tree | cabd3c993e97d09a00f68896c204ef1806664cf6 | |
| parent | 6cd126ef14920341524bf7f54100443c8e2345c1 (diff) | |
| download | advent-of-code-fd8bd06069ff4b461de131f07b72316e7955f37d.tar.gz advent-of-code-fd8bd06069ff4b461de131f07b72316e7955f37d.tar.bz2 advent-of-code-fd8bd06069ff4b461de131f07b72316e7955f37d.zip | |
cleanup
| -rw-r--r-- | 2023/src/day21.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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<string>& lines) | |||
| 38 | { | 38 | { |
| 39 | static const vector<position> movements = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } }; | 39 | static const vector<position> movements = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } }; |
| 40 | 40 | ||
| 41 | const auto height = lines.size(); | ||
| 42 | const auto width = lines[0].size(); | ||
| 43 | |||
| 41 | set<position> neighbours; | 44 | set<position> neighbours; |
| 42 | const auto [row, col] = pos; | 45 | const auto [row, col] = pos; |
| 43 | 46 | ||
| @@ -45,7 +48,7 @@ find_neighbours(position pos, const vector<string>& lines) | |||
| 45 | const auto nrow = row + drow; | 48 | const auto nrow = row + drow; |
| 46 | const auto ncol = col + dcol; | 49 | const auto ncol = col + dcol; |
| 47 | 50 | ||
| 48 | if ( nrow < lines.size() && ncol < lines[0].size() && (lines[nrow][ncol] == '.' || lines[nrow][ncol] == 'S') ) { | 51 | if ( nrow < height && ncol < width && lines[nrow][ncol] != '#' ) { |
| 49 | neighbours.emplace(nrow, ncol); | 52 | neighbours.emplace(nrow, ncol); |
| 50 | } | 53 | } |
| 51 | } | 54 | } |
