Created
October 11, 2022 18:04
-
-
Save jose-mdz/536421e97888a5f38b6ae173154acbfe to your computer and use it in GitHub Desktop.
Rows & Cols
This file contains 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 getIndex = (row: number, col: number, width: number) => width * row + col; | |
const getRowCol = (index: number, width: number) => [Math.floor(index / width), index % width]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment