How to select specific item from cartesian product without calculating every other item
I'm mostly convinced that there is an answer to this problem, but for the life of me can't figure out how to do it. Let's say I have three sets: A = [ 'foo', 'bar', 'baz', 'bah' ] B = [ 'wibble', 'wobble', 'weeble' ] C = [ 'nip', 'nop' ] And I know how to calculate the cartesian / cross product, (ant it's covered all over the place, on this site and elsewhere) so I won't go over that here. What I'm looking for is an algorithm that would allow me to simply select a specific item from the cartesian product without generating the whole set or iterating until I reach the nth item. Of course, I