From e68cf2fdb58dc10900ab5468d6ae2e97137b3c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 26 Dec 2018 13:05:28 +0100 Subject: [PATCH] Permutations --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 12eb2fb..8d2cc7c 100644 --- a/README.md +++ b/README.md @@ -875,16 +875,21 @@ from itertools import * [('a', 'b'), ('a', 'c'), ('b', 'c')] >>> combinations_with_replacement('abc', 2) -[('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'b'), ('b', 'c'), ('c', 'c')] +[('a', 'a'), ('a', 'b'), ('a', 'c'), + ('b', 'b'), ('b', 'c'), ('c', 'c')] >>> permutations('abc', 2) -[('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'c'), ('c', 'a'), ('c', 'b')] +[('a', 'b'), ('a', 'c'), + ('b', 'a'), ('b', 'c'), + ('c', 'a'), ('c', 'b')] >>> product('ab', [1, 2]) -[('a', 1), ('a', 2), ('b', 1), ('b', 2)] +[('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)] +[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), + (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)] ``` ### Infinite iterators