Cartesian products of lists

René Descartes (31 March 1596 — 11 February 1650) was a French writer,
philosopher and mathematician who spent most of his adult life in the
Dutch Republic. In this problem, you are asked to compute the Cartesian
product of lists of integer numbers. For instance, the cartesian product
of [[1, 2, 3], [4, 5]] is
[[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]].

Input

Input consists of several lists of sublists of integer numbers, each on
a line. Every list ends with a dot. Sublists are separated with bars.
Numbers are separated with commas. Each list and each sublist has, at
least, one element.

Output

For every list, print its Cartesian product following the format of the
sample output.

Problem information

Author: Jordi Petit

Generation: 2026-01-25T11:34:26.558Z

© Jutge.org, 2006–2026.
https://jutge.org
