- #1
mathmari
Gold Member
MHB
- 5,049
- 7
Hey!
I want to write a progarmm in python that reads two lists A, B and checks if the one of the lists is a circular shift of the other list. The result is either True or False.
I thought to do something like that:
But it cannot be correct because if we consider the lists A=[1, 2, 3, 4, 5] and B=[2, 3, 4, 1, 5], the sorted lists are the same, but B is not a circular shift of A. Right? (Wondering)
Could you give me a hint? (Wondering)
I want to write a progarmm in python that reads two lists A, B and checks if the one of the lists is a circular shift of the other list. The result is either True or False.
I thought to do something like that:
Code:
if sorted(A) == sorted(B):
C = True
else:
C = False
But it cannot be correct because if we consider the lists A=[1, 2, 3, 4, 5] and B=[2, 3, 4, 1, 5], the sorted lists are the same, but B is not a circular shift of A. Right? (Wondering)
Could you give me a hint? (Wondering)