On Sunday, August 2, 2015 at 1:05:32 AM UTC+2, Oscar Benjamin wrote: > Do you really need the canonical rotation or just a hash that is invariant > under rotations?
Having that canonical rotation would make the code simpler and faster, probably, but a rotationally invariant hash is a good start. > I don't know of a solution to the former that is better than what you already > have but the latter is an easier problem: Find the minimum element. Compute > the hash of the rotated sequence for each occurrence of the least common > element. Add those hashes together or multiply them or some similar > operation. That's your hash that will compare equal for any rotation of a > given sequence. Yes, that sounds like an idea if I decide to just go with the hash. Thanks! Lukas -- https://mail.python.org/mailman/listinfo/python-list