From: "Chr. Rippel" Date: 2002-02-07T20:03:34+09:00 Subject: Re: shuffle (all possible sequences) "Tobias Reif" wrote, .... > > "abc".consists_of?("abc") # -> true > > "acb".consists_of?("abc") # -> true > > "bac".consists_of?("abc") # -> true > > "bca".consists_of?("abc") # -> true > > > > And then, how can I say > > > > word_list = ['foo', 'bca'] > > word_list.include? word_consisting_of('abc') > > # => true > > > This seems to do the trick: Well it depends if you want to permit repetitions - i.e. what would be the outcome of "abbbc".consists_of? "abc" # should be false, right? in which case something like class String def consists_of? (other) return false unless length == other.length tmp = other rep = '' each_byte do |i| return false unless tmp.sub!(i.chr,rep) end return true end end would do the trick - the second question is harder (at least if you want to do it efficiently) /Christoph