August 2018
Intermediate to advanced
366 pages
10h 14m
English
The Cartesian product is usually what people think of when talking about combinations and permutations.
>>> import itertools
>>> c = itertools.product(('A', 'B', 'C'), repeat=2)
>>> list(c)
[('A', 'A'), ('A', 'B'), ('A', 'C'),
('B', 'A'), ('B', 'B'), ('B', 'C'),
('C', 'A'), ('C', 'B'), ('C', 'C')]
>>> c = itertools.permutations(('A', 'B', 'C'), 2)
>>> list(c)
[('A', 'B'), ('A', 'C'),
('B', 'A'), ('B', 'C'),
('C', 'A'), ('C', 'B')]