-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
from day16.lib.cells import ( | ||
BackSlashCell, | ||
Cell, | ||
DashCell, | ||
DotCell, | ||
ForwardSlashCell, | ||
PipeCell, | ||
) | ||
from day16.lib.direction import Direction | ||
from day16.lib.laser import Laser | ||
|
||
WEST_LASER = Laser(5, 4, Direction.WEST) | ||
EAST_LASER = Laser(5, 6, Direction.EAST) | ||
NORTH_LASER = Laser(4, 5, Direction.NORTH) | ||
SOUTH_LASER = Laser(6, 5, Direction.SOUTH) | ||
|
||
|
||
def test_dotcell() -> None: | ||
laser: Laser = Laser(5, 5, Direction.NORTH) | ||
cell: Cell = DotCell() | ||
assert cell.next_lasers(laser) == [NORTH_LASER] | ||
|
||
laser.direction = Direction.EAST | ||
assert cell.next_lasers(laser) == [EAST_LASER] | ||
|
||
laser.direction = Direction.WEST | ||
assert cell.next_lasers(laser) == [WEST_LASER] | ||
|
||
laser.direction = Direction.SOUTH | ||
assert cell.next_lasers(laser) == [SOUTH_LASER] | ||
|
||
|
||
def test_dashcell() -> None: | ||
laser: Laser = Laser(5, 5, Direction.NORTH) | ||
cell: Cell = DashCell() | ||
|
||
assert set(cell.next_lasers(laser)) == {WEST_LASER, EAST_LASER} | ||
|
||
laser.direction = Direction.EAST | ||
assert cell.next_lasers(laser) == [EAST_LASER] | ||
|
||
laser.direction = Direction.WEST | ||
assert cell.next_lasers(laser) == [WEST_LASER] | ||
|
||
laser.direction = Direction.SOUTH | ||
assert set(cell.next_lasers(laser)) == {WEST_LASER, EAST_LASER} | ||
|
||
|
||
def test_pipecell() -> None: | ||
laser: Laser = Laser(5, 5, Direction.NORTH) | ||
cell: Cell = PipeCell() | ||
|
||
assert cell.next_lasers(laser) == [NORTH_LASER] | ||
|
||
laser.direction = Direction.EAST | ||
assert set(cell.next_lasers(laser)) == {NORTH_LASER, SOUTH_LASER} | ||
|
||
laser.direction = Direction.WEST | ||
assert set(cell.next_lasers(laser)) == {NORTH_LASER, SOUTH_LASER} | ||
|
||
laser.direction = Direction.SOUTH | ||
assert cell.next_lasers(laser) == [SOUTH_LASER] | ||
|
||
|
||
def test_forwardslashcell() -> None: | ||
laser: Laser = Laser(5, 5, Direction.NORTH) | ||
cell: Cell = ForwardSlashCell() | ||
|
||
assert cell.next_lasers(laser) == [EAST_LASER] | ||
|
||
laser.direction = Direction.EAST | ||
assert cell.next_lasers(laser) == [NORTH_LASER] | ||
|
||
laser.direction = Direction.WEST | ||
assert cell.next_lasers(laser) == [SOUTH_LASER] | ||
|
||
laser.direction = Direction.SOUTH | ||
assert cell.next_lasers(laser) == [WEST_LASER] | ||
|
||
|
||
def test_backslashcell() -> None: | ||
laser: Laser = Laser(5, 5, Direction.NORTH) | ||
cell: Cell = BackSlashCell() | ||
|
||
assert cell.next_lasers(laser) == [WEST_LASER] | ||
|
||
laser.direction = Direction.EAST | ||
assert cell.next_lasers(laser) == [SOUTH_LASER] | ||
|
||
laser.direction = Direction.WEST | ||
assert cell.next_lasers(laser) == [NORTH_LASER] | ||
|
||
laser.direction = Direction.SOUTH | ||
assert cell.next_lasers(laser) == [EAST_LASER] |