title: Ruby's Array Combination Method
body: <p>I am going through the problems on Ruby Monk's Ruby Primer. </p>
  
  <p>Problem Statement
  Given a 3 or 4 digit number with distinct digits, return a sorted array of all the unique numbers that can be formed with those digits.
  Example:
  Given: 123
  Return: [123, 132, 213, 231, 312, 321]</p>
  
  <p>I thought that the Array#combination method would do the trick. My code looks like this:</p>
  
  <pre><code>def number_shuffle(number)
    # take integer and turn it into an array of digits
    digits = Array.new
  
    number.to_s.split('').each do |element|
      digits &lt;&lt; element.to_i
    end
  
    # shuffle the elements
    return digits.combination(digits.length).to_a
  end
  
  puts number_shuffle(123)
  </code></pre>
  
  <p>But the code above returns:</p>
  
  <pre><code>1
  2
  3
  </code></pre>
  
  <p>Not sure what I'm doing wrong here. I thought the documentation made it clear:</p>
  
  <p><a href="http://www.ruby-doc.org/core-2.2.0/Array.html#method-i-combination" rel="noreferrer">http://www.ruby-doc.org/core-2.2.0/Array.html#method-i-combination</a></p>
  
  <p>Any help is appreciated. </p>