0

My problem is that i have to generate all possible combinations for rows/columns when I have a constraint. Lets say a have a nonogram puzzle and its row has size of 40. And I have constraints

B,11,G,5,B,9

I have to follow a constraints:

  • there is always at least one empty box between two blocks of the boxes filled with the same color
  • there does not have to be an empty box between the boxes filled with different color
  • the order of the numbers in the legend corresponds to the order of the blocks of the boxes (from left to right, from top to bottom)

where letters stands for color (i.e. B = blue) and following is a length of that block. I have a class for that rules. And those rules are store in ArrayList Rules.

public class Rule {

public int size;
public char color;

public Rule(int length, char color){
    this.size = length;
    this.color= color;
}

now I want to generate all valid combinations for rows/cols so that I can add them to the ArrayList rowCombinations

for (int i =0 ; i < rowSize ; i++){             
    rowCombinations.add(makeCombinations(some_input));
}

and so that makeCombinations function would return mine custom variable class CSPVariable

public class CSPVariable {

public ArrayList<char[]> storage;
public int position;
public boolean Row;

public CSPVariable(int index, boolean Row) {
    this.position = index;
    this.Row = Row;
    this.storage = new ArrayList<>();
}

so to recap... given the rules I want to generate all possible combinations of letters and store it to char array storage int CSPVariable class.

David
  • 112
  • 1
  • 8
  • Could you please provide sample input and output – Sumeet Apr 07 '17 at 17:47
  • output : https://github.com/farkadav/Nonogram-solver/blob/master/krtek.txt.out.txt input : https://github.com/farkadav/Nonogram-solver/blob/master/krtkek.txt first two numbers are dimensions and then first 40 lines are row rules and other are col rules – David Apr 07 '17 at 17:52

0 Answers0