AOC2023: Fix day3 implementation
I accidently broke my day3 when messing with signed/unsigned integers
This commit is contained in:
parent
600bd7ee0f
commit
8344f2f9ab
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue