From: SATO Seichi Date: 2002-02-07T21:48:25+09:00 Subject: Re: shuffle (all possible sequences) This is anagram problem. On Thu, Feb 07, 2002 at 07:42:36PM +0900, 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 > faster to use unpack and sort a = self.unpack("C*").sort!.pack("C*") b = other.unpack("C*").sort!.pack("C*") See also ruby-talk 8142. -- SATO Seichi