from typing import Sequence def isRotation(L: Sequence, M: Sequence) -> bool: """Check if M is a rotation of L.""" L = list(L) M = list(M) if not len(L) == len(M): return False if not L and not M: return True for i in range(len(L)): if L[i:] + L[:i] == M: return True return False print("Testing isRotation()...", end="") assert isRotation([2, 3, 4, 5, 6], [4, 5, 6, 2, 3]) == True assert isRotation([2, 3, 4, 5, 6], [2, 3, 4, 5, 6]) == True assert isRotation([2, 3, 4, 5, 6], [2, 4, 3, 5, 6]) == False assert isRotation([1], []) == False assert isRotation([], []) == True print("Passed!")