Most pythonic way of rotating a circular list to a canonical point

Lukas Barth mail at tinloaf.de
Sun Aug 2 00:55:55 CEST 2015


On Sunday, August 2, 2015 at 12:32:25 AM UTC+2, Cameron Simpson wrote:
> Fine. This also eliminates any solution which just computes a hash.

Exactly.

> Might I suggest instead simply starting with the leftmost element in the first 
> list; call this elem0.  Then walk the second list from 0 to len(list2). If that 
> element equals elem0, _then_ compare the list at that point as you suggested.
>
> Is there an aspect of this which doesn't work?

The problem is: When I compute a hash over list1 (in its canonical form), I do not yet know list2 (or list3, or listN...) against which they will be compared later..
 
Lukas


More information about the Python-list mailing list