Skip to content

Instantly share code, notes, and snippets.

@emmettna
Created March 11, 2021 02:11
Show Gist options
  • Save emmettna/fe9fdaf5dd68d1de1cc0a3ac2cdeacc0 to your computer and use it in GitHub Desktop.
Save emmettna/fe9fdaf5dd68d1de1cc0a3ac2cdeacc0 to your computer and use it in GitHub Desktop.
calculate cell numbers hidden behind a spear line
// porivided width * height
// calculate the number of empty cells
// ex) [ ][ ][/]
// [ ][/][ ]
//. [/][ ][ ]
//
// gcd : https://gist.github.com/emmettna/702d972126d381dcceb8d8122ba7893c
def calcEmptyCells(width: Int, heght: Int): Int = width + heght - (gcd(width, heght))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment