On 19 May 2012 06:23, John O'Hagan <resea...@johnohagan.com> wrote: > To revisit a question which I'm sure none of you remember from when I posted > it > a year or so ago - there were no takers at the time - I'd like to try again > with > a more concise statement of the problem: > > How to generate only the distinct permutations of a sequence which are not > rotationally equivalent to any others? More precisely, to generate only the > most > "left-packed" of each group of rotationally equivalent permutations, such that > for each permutation p:
This makes me think of Lyndon words. A Lyndon word is a word which is the only lexicographical minimum of all its rotations. There is a very effective way of generating Lyndon words of length <= n. It may be possible to adapt it to what you want (obviously as Lyndon words are aperiodic you'd have to generate Lyndon word of length d | n when suitable). -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list