Skip to content

Instantly share code, notes, and snippets.

@ducaale
Last active December 29, 2022 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducaale/b2205f4f0f3ae665a0ad5116f18eb345 to your computer and use it in GitHub Desktop.
Save ducaale/b2205f4f0f3ae665a0ad5116f18eb345 to your computer and use it in GitHub Desktop.
I am tired of having to solve this again and again
const gridToLine = (x, y, width, height) => {
return (y * width) + x;
}
const lineTogrid = (a, width, height) => {
const x = a % width;
const y = a / width;
return [x, y]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment