Matrix Rotation
Start Timer
0:00:00
Given an array filled with random values, write a function rotate_matrix
to rotate the array by 90 degrees in the clockwise direction.
Example:
Input:
import numpy as np
array = np.array( [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]] )
array
1 | 2 | 3 | 4 | 5 |
2 | 3 | 4 | 5 | 6 |
3 | 4 | 5 | 6 | 7 |
4 | 5 | 6 | 7 | 8 |
5 | 6 | 7 | 8 | 9 |
Output:
5 | 4 | 3 | 2 | 1 |
6 | 5 | 4 | 3 | 2 |
7 | 6 | 5 | 4 | 3 |
8 | 7 | 6 | 5 | 4 |
9 | 8 | 7 | 6 | 5 |
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments