AOC2023: Fix day3 implementation

I accidently broke my day3 when messing with signed/unsigned integers
This commit is contained in:
Bananymous 2023-12-14 11:03:19 +02:00
parent 600bd7ee0f
commit 8344f2f9ab
1 changed files with 4 additions and 4 deletions

View File

@ -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;