Skip to content

Instantly share code, notes, and snippets.

@joshwcomeau
Last active July 20, 2016 12:27
Show Gist options
  • Save joshwcomeau/ac52e02bc7cf5a9cf69c6583ca6e1d1b to your computer and use it in GitHub Desktop.
Save joshwcomeau/ac52e02bc7cf5a9cf69c6583ca6e1d1b to your computer and use it in GitHub Desktop.
Snail
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