MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / rotate_180

Function rotate_180

matrix/rotate_matrix.py:40–49  ·  view source on GitHub ↗

>>> rotate_180(make_matrix()) [[16, 15, 14, 13], [12, 11, 10, 9], [8, 7, 6, 5], [4, 3, 2, 1]] >>> rotate_180(make_matrix()) == reverse_column(reverse_row(make_matrix())) True

(matrix: list[list[int]])

Source from the content-addressed store, hash-verified

38
39
40def rotate_180(matrix: list[list[int]]) -> list[list[int]]:
41 """
42 >>> rotate_180(make_matrix())
43 [[16, 15, 14, 13], [12, 11, 10, 9], [8, 7, 6, 5], [4, 3, 2, 1]]
44 >>> rotate_180(make_matrix()) == reverse_column(reverse_row(make_matrix()))
45 True
46 """
47
48 return reverse_row(reverse_column(matrix))
49 # OR.. reverse_column(reverse_row(matrix))
50
51
52def rotate_270(matrix: list[list[int]]) -> list[list[int]]:

Callers 1

rotate_matrix.pyFile · 0.85

Calls 2

reverse_rowFunction · 0.85
reverse_columnFunction · 0.85

Tested by

no test coverage detected