Skip to main content
2 of 2
edited tags

How to judge whether two groups of sequences are equal in cycles?

There's a set of arrays that I want to remove repeated elements that are equal after rotation:

arr = {{1, 2, 3, 4, 5}, {2, 3, 4, 5, 1}, {5, 1, 2, 3, 4}, {4, 3, 2, 5,1}};

The elements {1, 2, 3, 4, 5}, {2, 3, 4, 5, 1}and {5, 1, 2, 3, 4}are the same after operation RotateLeft. I want to delete the duplicate elements and only get {1, 2, 3, 4, 5} and {4, 3, 2, 5, 1}.

DeleteDuplicates[arr, RotateLeft[#1] == #2 &]

However, the above operation can only delete the elements that are equal after one shift.