On Sat, Dec 21, 2013 at 8:56 AM, Jim Whittaker <lists / ruby-forum.com> wrote:
> I am trying to make an array of all different combinations of a string.
> The minimum amount of chars in the output string must be two.
>
>     # Example string.  But what if string is n chars long though?
>     s = "string"

I would strongly suggest that this is an excellent opportunity to get
in the habit of writing tests that describe the behavior you want and
using those to drive discovery of the solution :-)

However, just one possibility:

require 'active_support/core_ext/array'  # small cheat :-)

s = "antidisestablishmentarianism"
result = []
(s.length - 1).times do |i|
  result << s.split(//).in_groups_of(i+1).map(&:compact).map(&:join)
end
puts result.flatten.uniq.reject{ |str| str.length == 1 }


FWIW,
-- 
Hassan Schroeder ------------------------ hassan.schroeder / gmail.com
http://about.me/hassanschroeder
twitter: @hassan