Skip to content

Instantly share code, notes, and snippets.

@thomasvaeth
Last active February 12, 2018 21:50
Show Gist options
  • Save thomasvaeth/0740360813ca950aee3b2a70a9c69839 to your computer and use it in GitHub Desktop.
Save thomasvaeth/0740360813ca950aee3b2a70a9c69839 to your computer and use it in GitHub Desktop.
"Opportunities lie in the place where the complaints are." - Jack Ma
function seatsInTheater(numCols, numRows, myCol, myRow) {
var calcCols = myCol > numCols / 2 ? numCols - myCol + 1 : myCol,
unblocked = ((numCols - calcCols) * numRows) + ((myRow - 1) * calcCols);
return numCols * numRows - unblocked - 1;
}
seatsInTheater(16, 11, 5, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment