From: David Alan Black Date: 2002-02-07T22:33:01+09:00 Subject: RE: shuffle (all possible sequences) Hello -- On Thu, 7 Feb 2002, SHULTZ,BARRY (HP-Israel,ex1) wrote: > Hi, > Your solution will test true ( 0, in your case ) > for "bbb".consists_of("abc"). Is that what you want? > > Here's a different solution that will only return true if > the two words have the exact same length and the > exact same letters: > > def consists_of? (other) > a = self.split(//) > b = other.split(//) > a.sort == b.sort > end Or, if you want to use the fabulous strbsrt extension available on RAA: require 'strbsrt' class String def consists_of?(other) sort_bytes == other.sort_bytes end end (Wow! What genius contributed that extension? :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav