Skip to content

Commit

Permalink
add left
Browse files Browse the repository at this point in the history
  • Loading branch information
Stegallo committed Dec 8, 2024
1 parent f567a13 commit 588c92f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions common/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,27 @@ def __hash__(self) -> int:
return hash((self.x, self.y))

def right(self):
if (self.y, self.x) == (-1, 0):
if self.icon == "^":
return Direction(0, 1, ">")
if (self.y, self.x) == (0, 1):
if self.icon == ">":
return Direction(1, 0, "v")
if (self.y, self.x) == (1, 0):
if self.icon == "v":
return Direction(0, -1, "<")
if (self.y, self.x) == (0, -1):
if self.icon == "<":
return Direction(-1, 0, "^")
raise Exception

def left(self):
if self.icon == "^":
return Direction(0, -1, "<")
if self.icon == ">":
return Direction(-1, 0, "^")
if self.icon == "v":
return Direction(0, 1, ">")
if self.icon == "<":
return Direction(1, 0, "v")
raise Exception

@staticmethod
def from_symbol(symbol: str):
return Direction(
Expand Down

0 comments on commit 588c92f

Please sign in to comment.