[EMAIL PROTECTED] writes: > George Sakkis: >> A faster algorithm is to create a 'key' for each word, defined as the >> tuple of ord differences (modulo 26) of consecutive characters. > > Very nice solution, it uses the same strategy used to find anagrams, > where keys are > "".join(sorted(word)) > Such general strategy to look for a possible invariant key for the > subsets of the required solutions is quite useful.
Or even: def get_key(word): initial = ord(word[0]) return tuple((ord(x) - initial) % 26 for x in word[1:]) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list