Skip to content

Instantly share code, notes, and snippets.

@jezinka

jezinka/Board.groovy Secret

Created Oct 16, 2018
Embed
What would you like to do?
Cell[] getRecord(int rowNum) { return board[rowNum] }
Cell[] getColumn(int colNum) { return (0..<board.length).collect { board[it][colNum] } }
Cell[] getSquare(int rowNum, int colNum) {
int beginRow = rowNum - rowNum % 3
int beginColumn = colNum - colNum % 3
return (beginRow..<beginRow + 3).collect { row ->
(beginColumn..<beginColumn + 3).collect { column ->
board[row][column]
}
}.flatten()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment