The rotate-matrix is an interesting new python module, which allows conversion of a matrix(2-D array) into either clockwise rotation or anti-clockwise rotation. It at present consists of only two methods. You can loop through these methods for ‘n’ number of rotations.
This module doesn’t come in-built with python but ca be installed using the following command:
pip install rotate-matrix
1) clockwise(): As obviously the name suggests, this function is used to rotate the matrix clockwise.
Parameter: Takes matrix as parameter which is of type list.
Return Value: passes the clock-wised rotated version of the matrix
[(6, 9, 7, 2), (2, 2, 6, 6), (5, 8, 3, 3)]
2) anti_clockwise(): This function of this module rotates the given matrix anti-clockwise.
Parameter: Takes matrix as parameter which is of type list
Return Value: passes the anti-clockwise rotated version of the matrix
[(3, 3, 8, 5), (6, 6, 2, 2), (2, 7, 9, 6)]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course