December 2018
Beginner to intermediate
796 pages
19h 54m
English
Last but not least, combinatoric generators. These are really fun, if you are into this kind of thing. Let's just see a simple example on permutations.
According to Wolfram Mathworld:
For example, there are six permutations of ABC: ABC, ACB, BAC, BCA, CAB, and CBA.
If a set has N elements, then the number of permutations of them is N! (N factorial). For the ABC string, the permutations are 3! = 3 * 2 * 1 = 6. Let's do it in Python:
# permutations.pyfrom itertools import permutations
print(list(permutations('ABC')))
This very short snippet of code produces ...
Read now
Unlock full access