From 9ecea0012b98f42debd536dc863b4ef2501eb859 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 15 Dec 2024 09:14:09 +0100 Subject: fixed old code for non-square maps --- 2024/04/day04b.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '2024/04/day04b.cpp') diff --git a/2024/04/day04b.cpp b/2024/04/day04b.cpp index 3d338d8..6e8a950 100644 --- a/2024/04/day04b.cpp +++ b/2024/04/day04b.cpp @@ -49,7 +49,7 @@ public: cells = new char[M * N]; for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) - cells[N*i + j] = j < (int)lines[i].size() ? + cells[M*i + j] = j < (int)lines[i].size() ? lines[i][j] : out_of_bound; } @@ -73,7 +73,7 @@ private: auto [i, j] = p; if (i >= N || i < 0 || j >= M || j < 0) return out_of_bound; - return cells[N*i + j]; + return cells[M*i + j]; } }; -- cgit v1.3