title: Limit combinations to a particular size
body: <p>I am trying to generate key and value combinations of elements stored in a Map></p>
  
  <p>eg: {3=[16], 2=[11, 12], 1=[5, 7], 0=[1, 3]}</p>
  
  <p>Need to get combinations as</p>
  
  <pre><code>                [0,1]-&gt; [[1,5],[1,7],[3,5],[3,7]]
                  [0,2]-&gt; [[1,11],[1,12],[3,11],[3,12]] and so on..
  </code></pre>
  
  <p>Currently I am able to get these combinations.</p>
  
  <p>But I am facing an issue
  1. I need to get only the combination for map.size -1 
   ie currently my results are</p>
  
  <pre><code>FINAL RESULT*** [3]===[ 16]
  FINAL RESULT*** [2]===[ 11,  12]
  FINAL RESULT*** [1]===[ 5,  7]
  FINAL RESULT*** [0]===[ 1,  3]
  FINAL RESULT*** [3, 2]===[ 16 11,  16 12]
  FINAL RESULT*** [3, 1]===[ 16 5,  16 7]
  FINAL RESULT*** [3, 0]===[ 16 1,  16 3]
  FINAL RESULT*** [2, 1]===[ 11 5,  11 7,  12 5,  12 7]
  FINAL RESULT*** [2, 0]===[ 11 1,  11 3,  12 1,  12 3]
  FINAL RESULT*** [1, 0]===[ 5 1,  5 3,  7 1,  7 3]
  FINAL RESULT*** [3, 2, 1]===[ 16 11 5,  16 11 7,  16 12 5,  16 12 7]
  FINAL RESULT*** [3, 2, 0]===[ 16 11 1,  16 11 3,  16 12 1,  16 12 3]
  FINAL RESULT*** [3, 1, 0]===[ 16 5 1,  16 5 3,  16 7 1,  16 7 3]
  FINAL RESULT*** [2, 1, 0]===[ 11 5 1,  11 5 3,  11 7 1,  11 7 3,  12 5 1,  12 5 3,  12 7 1,  12 7 3]
  FINAL RESULT*** [3, 2, 1, 0]===[ 16 11 5 1,  16 11 5 3,  16 11 7 1,  16 11 7 3,  16 12 5 1,  16 12 5 3,  16 12 7 1,  16 12 7 3]
  </code></pre>
  
  <p>I need only </p>
  
  <pre><code>FINAL RESULT*** [3, 2, 1]===[ 16 11 5,  16 11 7,  16 12 5,  16 12 7]
  FINAL RESULT*** [3, 2, 0]===[ 16 11 1,  16 11 3,  16 12 1,  16 12 3]
  FINAL RESULT*** [3, 1, 0]===[ 16 5 1,  16 5 3,  16 7 1,  16 7 3]
  FINAL RESULT*** [2, 1, 0]===[ 11 5 1,  11 5 3,  11 7 1,  11 7 3,  12 5 1,  12 5 3,  12 7 1,  12 7 3]
  </code></pre>
  
  <p>My current code is <a href="https://paste.ee/p/9oizB" rel="nofollow">here</a></p>
  
  <p>Where should I keep this condition?</p>