Skip to content

Commit

Permalink
Create determine-matrix-obtainable.py
Browse files Browse the repository at this point in the history
Determines whether the target matrix is obtainable by some rotation of the original matrix.
  • Loading branch information
gabedonnan authored Jan 15, 2023
1 parent 178fd93 commit bb06a7f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions determine-matrix-obtainable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution:
def findRotation(self, mat: List[List[int]], target: List[List[int]]) -> bool:
for i in range(4):
if mat == target:
return True
mat = self.rotOnce(mat)
return False

def rotOnce(self, matrix: List[List[int]]) -> List[List[int]]:
return [[matrix[-(j+1)][i] for j in range(len(row))] for i,row in enumerate(matrix)]

0 comments on commit bb06a7f

Please sign in to comment.