aboutsummaryrefslogtreecommitdiff
path: root/2024/12/day12a.cpp
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-12-15 09:14:09 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2024-12-15 09:14:09 +0100
commit9ecea0012b98f42debd536dc863b4ef2501eb859 (patch)
tree300c71eb7e7c2c5c749eb3cc0b35a955d32385f2 /2024/12/day12a.cpp
parente2a90aab7febe9ca73661d17a26fcb0dd10a68a7 (diff)
downloadaoc-9ecea0012b98f42debd536dc863b4ef2501eb859.tar.gz
aoc-9ecea0012b98f42debd536dc863b4ef2501eb859.zip
fixed old code for non-square maps
Diffstat (limited to '')
-rw-r--r--2024/12/day12a.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/2024/12/day12a.cpp b/2024/12/day12a.cpp
index b972fd2..89cc3d9 100644
--- a/2024/12/day12a.cpp
+++ b/2024/12/day12a.cpp
@@ -46,8 +46,8 @@ public:
46 cells = new char[M * N]; 46 cells = new char[M * N];
47 for (int i = 0; i < N; i++) { 47 for (int i = 0; i < N; i++) {
48 for (int j = 0; j < M; j++) { 48 for (int j = 0; j < M; j++) {
49 region[N*i + j] = -1; 49 region[M*i + j] = -1;
50 cells[N*i + j] = j < (int)lines[i].size() ? 50 cells[M*i + j] = j < (int)lines[i].size() ?
51 lines[i][j] : out_of_bound; 51 lines[i][j] : out_of_bound;
52 } 52 }
53 } 53 }
@@ -74,7 +74,7 @@ private:
74 74
75 int coord(pair<int, int> p) { 75 int coord(pair<int, int> p) {
76 auto [i, j] = p; 76 auto [i, j] = p;
77 return i >= N || i < 0 || j >= M || j < 0 ? -1 : N*i + j; 77 return i >= N || i < 0 || j >= M || j < 0 ? -1 : M*i + j;
78 } 78 }
79}; 79};
80 80

Generated with cgit - Back to sebastiano.tronto.net