8

Say we have the following two lists:

L1 = [1, 2, 3, 4, 5] and L2 = [4, 5, 1, 2, 3]

These can be considered the same because the rotation of L1 two indexes to the right will yield in L2.

This solution is simple enough, just keep rotating the list by 1 each time until it matches L2, what i'm trying to figure out is if it's possible to determine if these two lists are the same by finding some sort of pattern or equation in which when the two lists are plugged in the output is the same number, thus indicating that the lists are in fact identical (in terms of circularity).

Is this possible? Or is this something that would involve advanced math?

Edit: Not trying to find the fastest way to determine circularity or the least amount of computation. I'm trying to find out if a list can be quantified in such a way that a different list with the same circularity has the same signature and thus the lists are considered the same. Is there a function or equation that can solve this? i.e

f(L1) = X and f(L2) = X 

Since X = X, these two lists are circularly identical.

Ryan Smith
  • 709
  • 1
  • 7
  • 14
  • as in they contain the same numbers? Will each number in the list be unique or can they duplicate – A. L Feb 28 '17 at 00:58
  • They can be duplicate – Ryan Smith Feb 28 '17 at 01:36
  • check if the linked 'duplicate' answer is what you want. Also that answer assumes that the numbers will be in the same order. So if you have [1,2,3,4,5] and what you have is [2,3,1,4,5] are they supposed to be the same, or different? – A. L Feb 28 '17 at 01:38
  • The duplicate answer thread discusses efficiency of the rotation algorithm. And the two lists you provided are different because they are not rotations of each other – Ryan Smith Feb 28 '17 at 01:50

0 Answers0