From: Alexander Antonakakis Date: 2010-02-25T21:09:54+09:00 Subject: Re: Help on algorithm to calculate combinations Giampiero Zanchi wrote: > 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')} It produces the 1 children option plus the empty room one. We have the same results 14 for you that don't iclure the empty room combination and 15 for me with the empty room. -- Posted via http://www.ruby-forum.com/.