From: Regis d'Aubarede Date: 2013-04-15T04:57:33+09:00 Subject: Re: Looking for more elegant solutions. Hello, Maybe this one is a little more elegant : def f( accu,already, n, times ) if n > times accu << already.dup else ((1..times).to_a - already-[n]).each do |i| f( accu, already+[i], n+1, times ) end accu end end p f([],[],1,4) -- Posted via http://www.ruby-forum.com/.