title: Creating combinations with restrictions to each element without retrospective filtering
body: <p>I need to create all combinations of a list but each element has a lower and upper boundary (increasing with each digit by +2). </p>
  
  <p>For example with n=4:
  All combinations from [0, 1, 2, 3] (lower boundaries) to [0, 2, 4, 6] (upper boundaries) should result in:</p>
  
  <pre><code>[[0, 1, 2, 3],
   [0, 1, 2, 4],
   [0, 1, 2, 5],
   [0, 1, 2, 6],
   [0, 1, 3, 4],
   [0, 1, 3, 5],
   [0, 1, 3, 6],
   [0, 1, 4, 5],
   [0, 1, 4, 6],
   [0, 2, 3, 4],
   [0, 2, 3, 5],
   [0, 2, 3, 6],
   [0, 2, 4, 5],
   [0, 2, 4, 6]]
  </code></pre>
  
  <p>The straight forward solution is to use <code>itertools.combinations(range(2*n-1),n)</code> and then filter out all non-valid. But that creates lots of invalid combinations first and then is further slowed down by a filter run through all. That is too inefficient for large n in my case.</p>
  
  <p>I need a solution that does not even attempt to loop higher for each digit than possible and only create combinations within the boundaries for each digit. </p>
  
  <p>I'm sure there is a simple solution with nested loops or backtracking but I can't find it.</p>