Introduction to Discrete Mathematics for Computer Science Specialization | Combinatorics and Probability
这里用到Python代码
2 Combinatorics and Probability
2.1 Week1
2.1.1 Basic Counting
2.1.1.1 Starting to Count
-
Sum rule
-
Product rule
2.1.1.2 Recursive Counting
2.1.1.3 Tuple and Permutations
求每一类的话用减法
- Complement rule
2.2 Week2
2.2.1 Binomial Cofficients
2.2.1.1 Combinations
Rule of Sum
print(['Alice', 'Bob', 'Charlie'] + [0, 1, 2, 3, 4])
Rule of Product
from itertools import product
for p in product(['a', 'b', 'c'], ['x', 'y']):
print("".join(p))
Tuples
from itertools import product
for p in product("ab", repeat=3):
print("".join(p))
Permutations
from itertools import permutations
for p in permutations("abcd", 2):
print("".join(p))