Browse Source

Combinatorics

pull/27/head
Jure Šorn 5 years ago
parent
commit
d9f36c4a55
1 changed files with 8 additions and 8 deletions
  1. 16
      README.md

16
README.md

@ -436,6 +436,14 @@ from itertools import combinations, combinations_with_replacement, permutations,
``` ```
```python ```python
>>> product([0, 1], repeat=3)
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1),
(1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
>>> product('ab', '12')
[('a', '1'), ('a', '2'),
('b', '1'), ('b', '2')]
>>> combinations('abc', 2) >>> combinations('abc', 2)
[('a', 'b'), ('a', 'c'), ('b', 'c')] [('a', 'b'), ('a', 'c'), ('b', 'c')]
@ -448,14 +456,6 @@ from itertools import combinations, combinations_with_replacement, permutations,
[('a', 'b'), ('a', 'c'), [('a', 'b'), ('a', 'c'),
('b', 'a'), ('b', 'c'), ('b', 'a'), ('b', 'c'),
('c', 'a'), ('c', 'b')] ('c', 'a'), ('c', 'b')]
>>> product('ab', '12')
[('a', '1'), ('a', '2'),
('b', '1'), ('b', '2')]
>>> product([0, 1], repeat=3)
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1),
(1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
``` ```

Loading…
Cancel
Save