Skip to content

Commit

Permalink
Refactor Day 15 Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Dec 15, 2024
1 parent 5817067 commit bf29a23
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/AdventOfCode.Puzzles/2024/15/Part2/Part2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ private bool CanMove(Point position, Point direction)
{
var newPosition = position + direction;
var currentTile = _map[position.X, position.Y];
var newTile = _map[newPosition.X, newPosition.Y];

if (currentTile == '.')
{
Expand All @@ -129,6 +128,8 @@ private bool CanMove(Point position, Point direction)
return false;
}

var newTile = _map[newPosition.X, newPosition.Y];

if (currentTile == '[' || currentTile == ']')
{
if ((currentTile == ']' && direction == (-1, 0)) ||
Expand All @@ -149,11 +150,6 @@ private bool CanMove(Point position, Point direction)

return CanMove(newPosition, direction);
}

if (newTile == '.')
{
return true;
}

if (currentTile == '@')
{
Expand Down

0 comments on commit bf29a23

Please sign in to comment.