title: Finding every possible "non-duplicate" combination given a set of 6 digits
body: <p>So I was first asked to create a function to find ever possible combination given a set of 6 numbers that can range from 0-9 <strong>EDIT</strong> Keep in mind that the user is given a prompt for the input so the input can change or be different.. so in other words the input would be 123456 or 099384 <strong>END EDIT</strong>. This function would have to return every possible combination for a result of 3 digits while using the inputted 6 digits a repeatable amount of times.. So it would return like 111 112 113 etc..</p>
  
  <p>. I'm a php/javascript user and opted for javascript so that it can be run in the browser on a offline file.</p>
  
  <p>This is what I've built below which works well.</p>
  
  <pre><code>function findthree(nums) {
      for (var i = 0; i &lt; 10; i++) {
          if (in_array(i, nums)) {
              for (var ii = 0; ii &lt; 10; ii++) {
                  if (in_array(ii, nums)) {
                      for (var iii = 0; iii &lt; 10; iii++) {
                          if (in_array(iii, nums)) {
                              $('body').append('&lt;div&gt;' + i + '' + ii + '' + iii + '&lt;/div&gt;');
                          }
                      }
                  }
              }
          }
      }
  
  }
  
  
  function in_array(needle, haystack) {
      var length = haystack.length;
      for (var i = 0; i &lt; length; i++) {
          if (haystack[i] == needle) return true;
      }
      return false;
  }
  </code></pre>
  
  <p><strong>My Question Is</strong>.. How would I create a similar function that shows every combination EXCEPT "combination duplicates". In other words, the function will not return 211 because 112 was already returned and 654 will not be returned because 456 would of already been returned. I was going to attempt to use a array_difference function but can not figure it out completely how that would work.</p>
  
  <p>Thank you in advance for any help.</p>
  
  <p>EDIT Answer found with help of the answer I selected </p>
  
  <pre><code>function findthreenodupe(nums) {
      nums = $.distinct(nums);
      nums.sort(function(a, b) {
          return a - b
      });
      alert(nums);
      for (var i = 1; i &lt; 10; i++) {
          if (in_array(i, nums)) {
              for (var ii = i; ii &lt; 10; ii++) {
                  if (in_array(ii, nums)) {
                      for (var iii = ii; iii &lt; 10; iii++) {
                          if (in_array(iii, nums)) {
                              $('body').append('&lt;div&gt;' + i + '' + ii + '' + iii + '&lt;/div&gt;');
                          }
                      } // end of iii for loop
                  } // end of ii for loop
              } // end of i for loop
          }
      }
  }
  </code></pre>