+bool Board::is_valid() {
+ bool seen[BOARD_SIZE];
+ for (int i = 0; i < BOARD_SIZE; i++) {
+ seen[i] = false;
+ }
+
+ for (int i = 0; i < BOARD_SIZE; i++) {
+ if (board[i] < 0 || board[i] >= BOARD_SIZE || seen[board[i]]) {
+ return false;
+ }
+ seen[board[i]] = true;
+ }
+
+ // Redundant because pigeon-hole-principle, but check anyway
+ for (int i = 0; i < BOARD_SIZE; i++) {
+ if (!seen[i]) {
+ return false;
+ }
+ }
+
+ return true;
+}
+