There is such a task: There are several arrays of possible numbers. There may be 2 such arrays, maybe 10, it does not matter. Also the size of arrays can be different. The task is as follows: it is necessary to randomly generate all non-repeating combinations of numbers from these arrays. For example,
const first : number[]= [1,2]; const second : number[] = [2,3,4]; const third : number[] = [3,4,5,6]; The task is as follows: it is necessary to generate non-repeating combinations of one number from each array. Those.
(1,2,5), (2,3,4), (1,4,6), (2,3,5) и т.д. Additional and mandatory limitation. When choosing a number from an array, we do not need to know which other two numbers lie inside this combination. Those. the algorithm must be stateless, i.e. stateless. Those. for example, the algorithm generated two combinations (1,2,5) and (2,3,4). And after the generation (2,3,4), the algorithm should not check whether such a combination was before (he does not and cannot do it, because he does not have a previous state).
Is it possible to solve this problem?