> max = 4
> @result = []
> (0..max).each do |x|
>   (0..(max - x)).each do |y|
>     @combination = []
>     x.times { @combination << "children" }
>     y.times { @combination << "men" }
>     @result << @combination
>   end
> end
> 
> Thank you very much
>> 4 children / 0 men

it doesn't produce 1 children (for instance)

results = []
0.upto(4) do |n|
  0.upto(2**n - 1) do |i|
    s = i.to_s(2).rjust(n,'0').split('').sort.join
    results << s unless results.include?(s)
  end
end

p results.map! {|e| e.tr('01','cm')}

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