Generate a sequence from Cartesian product that "maximizes diversity" First, let me say I'm sorry if this question is poorly defined or not rigorous enough (defining it rigorously is part of the problem, I guess). Also, I am posting here and not on stackoverflow because I am more interested on the mathematical aspect of this problem than the algorithmic one (I hope you get what I mean).
Say I have 3 set of objects $S_1, S_2, S_3$ of different cardinality. For instance, I will use $S_1=\{a,b\}$, $S_2=\{l, m, n\}$ and $S_3=\{x,y,w,z\}$.
I would like to enumerate the Cartesian product of these sets in such a way that one tuple and the next are "different", in the sense they should share the less number of common elements. For instance, $(a, l, x)$ and $(a, l, y)$ are less different than $(a, l, x)$ and $(b, m, y)$. There is not a concept of similarity between the elements in the sets, so that $x$ and $y$ are as different as $x$ and $w$ are.
So, to continue the example, a sequence which "maximizes diversity" between subsequent tuples of elements could be:
$(a,l,w), (b,m,x), (a,n,y), (b,l,z), (a,m,w), (b,n,x), \dots$
Now, I would like to enumerate all the possible tuples of items, once and independently from the size of the sets (so, maybe, in this case I was lucky that the first 6 tuples had no duplicate elements).
I tried solving this problem by creating a mapping between the tuples of the Cartesian product and the integers, so that I could just generate numbers in modulo $|S_1|\cdot|S_2|\cdot|S_3|$, but I do not know what sequence of integers generate.
How can I do that?
Edit 1
So, this is additional information following the comments and the preliminary answer.
Yes, Hamming distance is a nice way to define what is "maximum diversity". I think I want to maximize the average over a path. Basically, I want the sequence to "look random".
Gray codes are indeed interesting, I know them but didn't think of them: thanks for the suggestion!
About the algorithm: yes, as a last instance I would like an algorithm, but I am actually curious about the math behind this problem, this is why this is so poorly defined.
As an addition, following a discussion with a person, she suggested me to use a strategy that is like Cantor's diagonal argument, but In my case it would be inside a 3 dimensional grid (tensor?), instead of a 2D. But I did not find an enumeration scheme so far (and did not come up with a strategy by myself).
I think this "3D Cantor diagonalization" is actually a good solution in my case, because in most of the transitions between one cell of the grid and the next, there is a variation in all the components of the tuples.
Right now, I think I will follow this path first, before trying with Gray codes.
 A: Interesting question. This is not an answer, but several comments that don't quite fit in a comment.
I think you have to clarify "maximum diversity". Your measure for a particular pair seems to be the Hamming distance: the number of places at which they differ. Do you want to maximize the sum or average over the path? Maximize the minimum difference? 
In the special case when all the cardinalities are $2$ you can think of this as a Hamiltonian path that visits all the vertices of the cube $\{0,1\}^n$. There is a name for such paths when your objective is to make just one bit change at a time. They are Gray codes. You have the opposite objective, but reading about Gray codes might help. 
Although you ask for mathematics rather than an algorithm, you do want to "generate". That does suggest an algorithm of some kind. 
There is lots of literature on algorithms to find Hamiltonian paths if they exist. In your case I think it should be easy to show directly that they do. The paths in your problem come with weights, and you want the heaviest one. You might be able to build that optimization into some existing algorithm.
There are recursive constructions for Gray codes you might be able to adapt.
