forked from Bananymous/banan-os
AOC2023: Remove unnecessary loop
This commit is contained in:
parent
00d57d783e
commit
58633ca373
|
@ -202,7 +202,7 @@ i64 puzzle2(FILE* fp)
|
|||
{
|
||||
for (u32& tile : row)
|
||||
{
|
||||
// Remove left and right from path
|
||||
// Remove left and right from path tiles
|
||||
if (tile & Flag::Path)
|
||||
tile &= ~(Flag::Left | Flag::Right);
|
||||
// Tile should never be both left and right
|
||||
|
@ -227,11 +227,8 @@ i64 puzzle2(FILE* fp)
|
|||
}
|
||||
ASSERT(enclosed != Flag::Path);
|
||||
|
||||
// Expand all enclosed areas
|
||||
bool modified = true;
|
||||
while (modified)
|
||||
{
|
||||
modified = false;
|
||||
// Expand all enclosed areas (only one pass is needed since exery area
|
||||
// is fully bordered by enclosed tiles)
|
||||
for (size_t y = 1; y < grid.size(); y++)
|
||||
{
|
||||
for (size_t x = 1; x < grid[y].size(); x++)
|
||||
|
@ -239,11 +236,7 @@ i64 puzzle2(FILE* fp)
|
|||
if (grid[y][x] & Flag::Mask)
|
||||
continue;
|
||||
if ((grid[y - 1][x] & enclosed) || (grid[y][x - 1] & enclosed))
|
||||
{
|
||||
grid[y][x] |= enclosed;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue