How to judge whether two groups of sequences are equal in cycles?
Another idea is to make use of the fact that Cycles
canonicalizes. For example:
Cycles[{{5,1,2,3,4}}]
Cycles[{{1, 2, 3, 4, 5}}]
So,
DeleteDuplicatesBy[arr, Cycles @* List]
{{1, 2, 3, 4, 5}, {4, 3, 2, 5, 1}}
If we consider the list elements as graph vertices with an edge between each consecutive pair (cyclically), then two lists are equivalent if they can be mapped to graphs with the same edges. In code:
graphs[list_] := <| # -> Sort@Thread[# -> RotateLeft[#]] & /@ list |>
So then:
graphs[arr]
(*
<| {1,2,3,4,5} -> {1->2, 2->3, 3->4, 4->5, 5->1}
, {2,3,4,5,1} -> {1->2, 2->3, 3->4, 4->5, 5->1}
, {5,1,2,3,4} -> {1->2, 2->3, 3->4, 4->5, 5->1}
, {4,3,2,5,1} -> {1->4, 2->5, 3->2 ,4->3, 5->1}
|>
*)
And:
DeleteDuplicatesBy[arr, graphs[arr]]
(* {{1,2,3,4,5}, {4,3,2,5,1}} *)
Maybe
DeleteDuplicatesBy[arr, Mod[# - #[[1]], 5] &]
does what you want. It replaces rotation operations by basuc integer arithmetic.
However, this exploits that only the numbers 1--5 appear in the lists. I don't know whether that is your actual use case...
The following would be a more general method:
DeleteDuplicatesBy[arr, RotateLeft[#, Ordering[#, -1][[1]] - 1] &]
It normalizes the entries of arr
by determining the smallest entry and rotating it in front.