From 8344f2f9ab68cdacdcc165a41fd97c43125e9de7 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 14 Dec 2023 11:03:19 +0200 Subject: [PATCH] AOC2023: Fix day3 implementation I accidently broke my day3 when messing with signed/unsigned integers --- userspace/aoc2023/day3/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/userspace/aoc2023/day3/main.cpp b/userspace/aoc2023/day3/main.cpp index 2f65b471e9..15cc49d57f 100644 --- a/userspace/aoc2023/day3/main.cpp +++ b/userspace/aoc2023/day3/main.cpp @@ -32,14 +32,14 @@ int puzzle1(FILE* fp) for (ssize_t y_off = -1; y_off <= 1; y_off++) { - if ((ssize_t)y < y_off) + if ((ssize_t)y + y_off < 0) continue; if (y + y_off >= lines.size()) break; for (ssize_t x_off = -1;; x_off++) { - if ((ssize_t)x < x_off) + if ((ssize_t)x + x_off < 0) continue; if (x + x_off >= lines[y + y_off].size()) break; @@ -111,14 +111,14 @@ int puzzle2(FILE* fp) for (ssize_t y_off = -1; y_off <= 1; y_off++) { - if ((ssize_t)y < y_off) + if ((ssize_t)y + y_off < 0) continue; if (y + y_off >= lines.size()) break; for (ssize_t x_off = -1;; x_off++) { - if ((ssize_t)x < x_off) + if ((ssize_t)x + x_off < 0) continue; if (x + x_off >= lines[y + y_off].size()) break;