From: "David A. Black" Date: 2008-05-04T21:59:10+09:00 Subject: Re: Array combination check Hi -- On Sun, 4 May 2008, Nadim Kobeissi wrote: > Xavier Noria wrote: >> What is a combination? > > Please allow me to make myself more clear: > bunny=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] > cow="hello" > > I want to test all possible combinations of the items inside bunny (the > alphabet) starting from the smallest to the biggest (a, then b, then c.. > then aa, then ab, then ac, etc.) until I arrive to a case in which the > combination == cow, which means the combination would be "hello". >> str = 'a' => "a" >> cow = "hello" => "hello" >> str.succ! until str == cow => nil >> str => "hello" David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates!