From: andrea Date: 2008-12-26T18:35:01+09:00 Subject: Buiding anamgrams I'm studying ruby (and I really love it even more than python) and I want to do a little exercise. I want to create an efficient module to generate every possible anagrams of a word, of any given size... I already done this in python, I want to see how can it be elegant in ruby... I need a good permutation algorithm (this http://www.cut-the-knot.org/Curriculum/Combinatorics/JohnsonTrotter.shtml works fine) and I'd like to use enumerators in the best and most efficient way. I also looked at callcc which is great for backtracking, could be used in this case?? thanks for any help A basic structure like that could be fine? class Anagrams attr :word include Enumerable include Comparable def <=>(other) self.word <=> other.word end def each(&block) @word.chars end def initialize(word) @word = word end end