(Not sure if that's the right SX site? I don't need actual code, so)I'm looking for an algorithm that generates all cartesian products for a list of sets, but skips tuples that are just rotations of previously issued tuples in a smart way.Here, $(a_0,\dotsc,a_n)$ is a rotation of $(b_0,\dotsc,b_n)$ iff $\exists x : \forall i \in [0,\dotsc,n]: a_i = b_j \text{ with } j = i + x \mod n$.For example, for $f(\{1, 2\}, \{1, 2, 3\})$ the output should be$\{(1,1), (1,2), (1,3), (2,2), (2,3)\}$, i.e. without $(2,1)$ because it's a rotation of $(1,2)$.
Algorithm for generating all cartesian products, without rotations
algorithms;combinatorics