title: Find out all possible combinations of a 2D boolean array given some criteria (using Java)
body: <p>Say there's a 2d boolean array</p>
  
  <pre><code>boolean[][] = {  x  x  x  x  x  x  x
                   x  x  x  x  x  x  x
                   x  x  x  x  x  x  x
                   x  x  x  x  x  x  x  }
  </code></pre>
  
  <p>Criteria:</p>
  
  <ol>
  <li>Each column must have 2 'true'</li>
  <li>Each row cannot have more than 4 'true'</li>
  </ol>
  
  <p>For example a solution can be:</p>
  
  <pre><code>boolean[][] = {  T  T  T  T  F  F  F
                   T  T  T  T  F  F  F
                   F  F  F  F  T  T  T
                   F  F  F  F  T  T  T  }
  </code></pre>
  
  <p>Another one:</p>
  
  <pre><code>boolean[][] = {  T  F  T  F  F  T  T
                   F  T  T  T  F  F  F
                   F  F  F  T  T  T  F
                   T  T  F  F  T  F  T  }
  </code></pre>
  
  <p>How to write a recursive function to find out all possible combinations given the two criteria above? </p>
  
  <p>I wish I can show something that I tried, but I don't even know how to start. I tried to solve this by using object oriented way, by creating class for the row or column but doesn't seem to help simplifying it since the rows and columns are closely affecting each other.</p>
  
  <p>Thanks in advance!</p>