Hassan Schroeder wrote in post #1131369:
> 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 }
>
>

    #=> ["st", "ri", "ng", "str", "ing", "stri", "strin"]

This is what I got for output running your equation.  Not quite there 
but thanks for the ideas.  Also can you elaborate on the "habit of 
writing tests" bit you mentioned?  Thanks :)

-- 
Posted via http://www.ruby-forum.com/.