Hi!
I have a list of numbers that I treat as "circular", i.e. [1,2,3] and [2,3,1]
should be the same. Now I want to rotate these to a well defined status, so
that I can can compare them.
If all elements are unique, the solution is easy: find the minimum element,
find its index, then use mylist
On Saturday, August 1, 2015 at 10:57:19 PM UTC+2, Marko Rauhamaa wrote:
>
> def circularly_equal(l1, l2):
> length = len(l1)
> if length != len(l2):
> return False
> twice = l1 + l1
> for i in range(len
On Saturday, August 1, 2015 at 10:51:03 PM UTC+2, Emile van Sebille wrote:
> Is the problem to determine if one list of circular numbers 'matches'
> another one despite rotation status? If so, I'd do something like:
Well.. no. I actually really need this "canonical" rotation, since I'm hashing
Perhaps I should clarify a bit:
- I definitely need a "canonical rotation" - just a comparison result is not
enough
- 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.
--
https://mail.python.org/m
On Saturday, August 1, 2015 at 11:37:48 PM UTC+2, Emile van Sebille wrote:
> Well, it looks to me that I don't know what a 'canonical rotation' is --
That's because it is not defined. ;)
I need a way to rotate one of these lists in a way so that it will produce the
same output every time, regar
On Saturday, August 1, 2015 at 11:43:28 PM UTC+2, Paul Rubin wrote:
> How large are these lists supposed to be?
Potentially large. Not so large though that iterating them (multiple times)
should be a problem.
> [Concatenated Hashes]
>
> If the lists are very large that doesn't sound so great d
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
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.