package ru.samsu.mj.board;

import ru.samsu.mj.collection.BoardCollection;

import java.util.ArrayList;
import java.util.List;

public class BoardGenerator {
    public static BoardCollection generateByDimension(int n) {
        List<Board> list = new ArrayList<>();
        generateByDimension(list, new int[n], new boolean[n], n, 0);
        BoardCollection boardCollection = BoardCollection.valueOf(list);
        return boardCollection;
    }

    private static void generateByDimension(List<Board> list, int[] current, boolean[] occCols, int n, int i) {
        if (i == n) {
            Board board = Board.valueOf(current);
            list.add(board);
            return;
        }

        generateByDimension(list, current, occCols, n, 1 + i);

        int max = n / 2 - Math.abs(n / 2 - i);
        for (int j = 0; j < max; j++) {
            if (occCols[j])
                continue;

            occCols[j] = true;
            current[i] = j;
            generateByDimension(list, current, occCols, n, 1 + i);
            occCols[j] = false;
            current[i] = -1;
        }
    }
}

@@ -97,16 +97,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -285,16 +285,82 @@
 st%3C%3E();%0A
+        int%5B%5D board = new int%5Bn%5D;%0A        Arrays.fill(board, -1);%0A
         
@@ -385,26 +385,21 @@
 n(list, 
-new int%5Bn%5D
+board
 , new bo
@@ -939,20 +939,111 @@
    i
-f (occCols%5Bj
+nt d = n - 1 - i - j;%0A            int i2 = i + d, j2 = j + d;%0A%0A            if (occCols%5Bj%5D %7C%7C occCols%5Bj2
 %5D)%0A 
@@ -1092,16 +1092,30 @@
 ols%5Bj%5D =
+ occCols%5Bj2%5D =
  true;%0A 
@@ -1137,24 +1137,54 @@
 ent%5Bi%5D = j;%0A
+            current%5Bi2%5D = j2;%0A
             
@@ -1262,16 +1262,30 @@
 ols%5Bj%5D =
+ occCols%5Bj2%5D =
  false;%0A
@@ -1313,16 +1313,46 @@
 %5D = -1;%0A
+            current%5Bi2%5D = -1;%0A
         

Fix BoardGenerator.