Last active
July 20, 2016 12:27
-
-
Save joshwcomeau/ac52e02bc7cf5a9cf69c6583ca6e1d1b to your computer and use it in GitHub Desktop.
Snail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const flipMatrix = matrix => ( | |
matrix[0].map((column, index) => ( | |
matrix.map(row => row[index]) | |
)) | |
); | |
const rotateMatrixCounterClockwise = matrix => ( | |
flipMatrix(matrix).reverse() | |
); | |
/* | |
[ [ | |
[1,2,3], [3,6,9], | |
[4,5,6], -> [2,5,8], | |
[7,8,9], [1,4,7], | |
]; ]; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment