Created
July 1, 2016 21:16
-
-
Save joshwcomeau/8a9c4f2ed3ab32514fdd4886e8e26e24 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 rotateMatrix = matrix => ( | |
flipMatrix(matrix.reverse()) | |
); | |
const rotateMatrixCounterClockwise = matrix => ( | |
flipMatrix(matrix).reverse() | |
); | |
const flipMatrixCounterClockwise = matrix => ( | |
rotateMatrix(matrix).reverse() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment