private boolean oneQueenPerRow() {
int foundQueens;
for (int i = 0; i < board.length; i++) {
foundQueens = 0;//each loop is a checked row
for (int j = 0; j < board.length; j++) {
if (board[i][j] == QUEEN)
foundQueens++;
}
if (foundQueens > 1) return false;
}
return true;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter