return x

def rotate_left(x):
    start = x
while True:
    x = x[1:] + x[0:1]
if x == start:
    break
yield x
x = maximal_difference_seeder(x)
rotated = [x] + (list(rotate_left(x)) if len(x) > 1 else [])
reflected = [e[::-1] for e in rotated] if len(x) > 2 else []
return map(tuple, rotated + reflected)
Reordering a list to maximize difference of adjacent elements