Учитывая неизвестное количество списков, каждый с неизвестной длиной, мне нужно создать уникальный список со всеми возможными уникальными комбинациями. Например, учитывая следующие списки:
X: [A, B, C]
Y: [W, X, Y, Z]
Затем я должен иметь возможность генерировать 12 комбинаций:
[AW, AX, AY, AZ, BW, BX, BY, BZ, CW, CX, CY, CZ]
Если был добавлен третий список из 3 элементов, у меня было бы 36 комбинаций и т.д.
Любые идеи о том, как я могу это сделать на Java?
(псевдокод тоже будет хорош)