Skip to content

Commit

Permalink
day18: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ong committed Dec 27, 2023
1 parent 80432cc commit fd7f799
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions day18/day18a.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Direction(StrEnum):
Left = "L"
Right = "R"

def __repr__(self) -> str:
def __repr__(self) -> str: # pragma: no cover
return str(self)

def __str__(self) -> str:
Expand All @@ -47,7 +47,7 @@ def generate_offsets(
return [Position(position.row + i, position.col) for i in range(1, steps + 1)]
if direction == Direction.Up:
return [Position(position.row - i, position.col) for i in range(1, steps + 1)]
raise ValueError(f"Direction not supported{direction}")
raise AssertionError(f"Direction not supported{direction}")


class Matrix:
Expand Down Expand Up @@ -92,7 +92,7 @@ def dig_out(self) -> None:
while not to_process.empty():
position: Position = to_process.get()
if self.is_oob(position):
continue
raise AssertionError("pre-allocated matrix shouldn't cause OOB")
if visited[position.row][position.col]:
continue
if self.contents[position.row][position.col].contents != ".":
Expand Down
2 changes: 1 addition & 1 deletion day18/day18b.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def process_command(command: Command, position: Position) -> Position:
return Position(position.row, position.col - command.steps)
if command.direction == Direction.Up:
return Position(position.row - command.steps, position.col)
raise ValueError(f"unsupported directoin {command.direction}")
raise AssertionError(f"unsupported directoin {command.direction}")


def calculate_area(positions: list[Position], perimeter: int) -> int:
Expand Down
2 changes: 2 additions & 0 deletions day18/tests/test_day18a.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ def test_day18a() -> None:
assert commands[0].steps == 6 and commands[0].direction == Direction.Right

assert get_solution(commands) == 62

assert str(Direction.Right) == "Right"

0 comments on commit fd7f799

Please sign in to comment.