From 8e31bee1adc6857b04f2b64f186cb30e72987edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 10 Feb 2023 15:45:13 +0100 Subject: [PATCH] Combinatorics --- README.md | 30 +++++++++++++++--------------- index.html | 36 ++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index bae4d74..2f49930 100644 --- a/README.md +++ b/README.md @@ -558,30 +558,30 @@ import itertools as it ``` ```python ->>> it.product('abc', 'abc') # a b c -[('a', 'a'), ('a', 'b'), ('a', 'c'), # a x x x - ('b', 'a'), ('b', 'b'), ('b', 'c'), # b x x x - ('c', 'a'), ('c', 'b'), ('c', 'c')] # c x x x +>>> it.product('abc', 'abc') # a b c +[('a', 'a'), ('a', 'b'), ('a', 'c'), # a x x x + ('b', 'a'), ('b', 'b'), ('b', 'c'), # b x x x + ('c', 'a'), ('c', 'b'), ('c', 'c')] # c x x x ``` ```python ->>> it.combinations('abc', 2) # a b c -[('a', 'b'), ('a', 'c'), # a . x x - ('b', 'c')] # b . . x +>>> it.combinations('abc', 2) # a b c +[('a', 'b'), ('a', 'c'), # a . x x + ('b', 'c')] # b . . x ``` ```python ->>> it.combinations_with_replacement('abc', 2) # a b c -[('a', 'a'), ('a', 'b'), ('a', 'c'), # a x x x - ('b', 'b'), ('b', 'c'), # b . x x - ('c', 'c')] # c . . x +>>> it.combinations_with_replacement('abc', 2) # a b c +[('a', 'a'), ('a', 'b'), ('a', 'c'), # a x x x + ('b', 'b'), ('b', 'c'), # b . x x + ('c', 'c')] # c . . x ``` ```python ->>> it.permutations('abc', 2) # a b c -[('a', 'b'), ('a', 'c'), # a . x x - ('b', 'a'), ('b', 'c'), # b x . x - ('c', 'a'), ('c', 'b')] # c x x . +>>> it.permutations('abc', 2) # a b c +[('a', 'b'), ('a', 'c'), # a . x x + ('b', 'a'), ('b', 'c'), # b x . x + ('c', 'a'), ('c', 'b')] # c x x . ``` diff --git a/index.html b/index.html index b99166c..6679748 100644 --- a/index.html +++ b/index.html @@ -500,24 +500,24 @@ Point(x=1, y=2 [(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)] -
>>> it.product('abc', 'abc')                    #   a  b  c
-[('a', 'a'), ('a', 'b'), ('a', 'c'),            # a x  x  x
- ('b', 'a'), ('b', 'b'), ('b', 'c'),            # b x  x  x
- ('c', 'a'), ('c', 'b'), ('c', 'c')]            # c x  x  x
-
-
>>> it.combinations('abc', 2)                   #   a  b  c
-[('a', 'b'), ('a', 'c'),                        # a .  x  x
- ('b', 'c')]                                    # b .  .  x
-
-
>>> it.combinations_with_replacement('abc', 2)  #   a  b  c
-[('a', 'a'), ('a', 'b'), ('a', 'c'),            # a x  x  x
- ('b', 'b'), ('b', 'c'),                        # b .  x  x
- ('c', 'c')]                                    # c .  .  x
-
-
>>> it.permutations('abc', 2)                   #   a  b  c
-[('a', 'b'), ('a', 'c'),                        # a .  x  x
- ('b', 'a'), ('b', 'c'),                        # b x  .  x
- ('c', 'a'), ('c', 'b')]                        # c x  x  .
+
>>> it.product('abc', 'abc')                     #   a  b  c
+[('a', 'a'), ('a', 'b'), ('a', 'c'),             # a x  x  x
+ ('b', 'a'), ('b', 'b'), ('b', 'c'),             # b x  x  x
+ ('c', 'a'), ('c', 'b'), ('c', 'c')]             # c x  x  x
+
+
>>> it.combinations('abc', 2)                    #   a  b  c
+[('a', 'b'), ('a', 'c'),                         # a .  x  x
+ ('b', 'c')]                                     # b .  .  x
+
+
>>> it.combinations_with_replacement('abc', 2)   #   a  b  c
+[('a', 'a'), ('a', 'b'), ('a', 'c'),             # a x  x  x
+ ('b', 'b'), ('b', 'c'),                         # b .  x  x
+ ('c', 'c')]                                     # c .  .  x
+
+
>>> it.permutations('abc', 2)                    #   a  b  c
+[('a', 'b'), ('a', 'c'),                         # a .  x  x
+ ('b', 'a'), ('b', 'c'),                         # b x  .  x
+ ('c', 'a'), ('c', 'b')]                         # c x  x  .
 

#Datetime

  • Module 'datetime' provides 'date' <D>, 'time' <T>, 'datetime' <DT> and 'timedelta' <TD> classes. All are immutable and hashable.