def cyclic_equals(seq1, seq2):
 seq2 = tuple(seq2)
 return any(((x == tuple(seq2)) for x in cycles(seq1)))

def cyclic_equals ( seq1 , seq2 ) : seq2 = tuple ( seq2 ) return any ( ( ( x == tuple ( seq2 ) ) for x in cycles ( seq1 ) ) )
decide whether two sequences are equal up to cyclic permutations .