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

Paul Rubin no.email at nospam.invalid
Sat Aug 1 23:43:14 CEST 2015


Lukas Barth <mail at tinloaf.de> writes:
> - It does not matter what that rotation is. Starting with the smallest
> element was just an idea by me, any rotation that can easily produced
> will do.

How large are these lists supposed to be?  If they're (say) 5 elements,
you could make the hash code consist of the concatenated hashes of each
of the 5 rotations, or maybe a Bloom filter on those hashes.  Then to do
a lookup, hash your target list and see if it appears in the table.

If the lists are very large that doesn't sound so great due to storage
requirements..


More information about the Python-list mailing list