title: extending permutation algorithm (including duplicates)
body: <p>I m looking for an algorithm that give all possible combinations of letters</p>
  
  <p>Let me explain better. If i have </p>
  
  <pre><code>base-letters = ["a","b","c"];
  depth = 2; //max chars allowed
  </code></pre>
  
  <p>then the expected result would be these 12 elements (<em>3^1 + 3^2 = 12</em>):</p>
  
  <pre><code>["a", "b", "c", "aa","ab","ac","ba","bb","bc","ca", "cb", "cc"]
  </code></pre>
  
  <p>If i had a depth value = 3, i would expect (3^1) + (3^2) + (3^3) = 39 elements</p>
  
  <pre><code>["a", "b", ... , "aa", "ab", ... , "aaa", "aab", ..., "aba", ...]
  </code></pre>
  
  <p>Now, if i understood correctly permutation algorithm is similar, but doesn't consider <strong>duplicated</strong> letters (like "aa","bb","aab", "aba"), and the <strong>variable depth</strong> value (it could be different then base-letters length).</p>