diff --git a/3248-snake-in-matrix/3248-snake-in-matrix.py b/3248-snake-in-matrix/3248-snake-in-matrix.py new file mode 100644 index 0000000..cb9fbb0 --- /dev/null +++ b/3248-snake-in-matrix/3248-snake-in-matrix.py @@ -0,0 +1,12 @@ +class Solution: + def finalPositionOfSnake(self, n: int, commands: List[str]) -> int: + movesCount = { + "RIGHT": 0, + "LEFT": 0, + "UP": 0, + "DOWN": 0, + } + for command in commands: + movesCount[command] += 1 + + return movesCount["RIGHT"] - movesCount["LEFT"] + n * (movesCount["DOWN"] - movesCount["UP"]) \ No newline at end of file