From a6e99ef3eef4c1b73074943c3daec1e683bf921b Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:45:36 +0300 Subject: [PATCH 1/3] adding the array_complement method --- boolean_algebra/array_complement.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 boolean_algebra/array_complement.py diff --git a/boolean_algebra/array_complement.py b/boolean_algebra/array_complement.py new file mode 100644 index 000000000000..e27badcedc23 --- /dev/null +++ b/boolean_algebra/array_complement.py @@ -0,0 +1,23 @@ +def array_complement(initial_lst: list, diff_lst: list) -> list: + """ + removes all values from list initial_lst which + are also present in list diff_lst [ while keeping + the initial order of the elements ] + + https://en.wikipedia.org/wiki/Complement_(set_theory) + + >>> array_complement([1, 6, 2, 8], [1, 4]) + [6, 2, 8] + >>> array_complement([146], [146, 25]) + [] + >>> array_complement([35], [36]) + [35] + + + """ + + return [c for c in initial_lst if c not in diff_lst] + + +if __name__ == "__main__": + __import__("doctest").testmod() From 797f2deb7eeec2d81d9da99c84813a1608288db4 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Wed, 17 Aug 2022 17:12:54 +0300 Subject: [PATCH 2/3] fixing indentation --- boolean_algebra/array_complement.py | 32 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/boolean_algebra/array_complement.py b/boolean_algebra/array_complement.py index e27badcedc23..3293801980f4 100644 --- a/boolean_algebra/array_complement.py +++ b/boolean_algebra/array_complement.py @@ -1,23 +1,23 @@ def array_complement(initial_lst: list, diff_lst: list) -> list: - """ - removes all values from list initial_lst which - are also present in list diff_lst [ while keeping - the initial order of the elements ] + """ + removes all values from list initial_lst which + are also present in list diff_lst [ while keeping + the initial order of the elements ] - https://en.wikipedia.org/wiki/Complement_(set_theory) + https://en.wikipedia.org/wiki/Complement_(set_theory) - >>> array_complement([1, 6, 2, 8], [1, 4]) - [6, 2, 8] - >>> array_complement([146], [146, 25]) - [] - >>> array_complement([35], [36]) - [35] - - - """ + >>> array_complement([1, 6, 2, 8], [1, 4]) + [6, 2, 8] + >>> array_complement([146], [146, 25]) + [] + >>> array_complement([35], [36]) + [35] + + + """ - return [c for c in initial_lst if c not in diff_lst] + return [c for c in initial_lst if c not in diff_lst] if __name__ == "__main__": - __import__("doctest").testmod() + __import__("doctest").testmod() From 87350cbd7602b5321d0c616b6d002514509aebd2 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Wed, 17 Aug 2022 17:20:54 +0300 Subject: [PATCH 3/3] following bot recommendations --- boolean_algebra/array_complement.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boolean_algebra/array_complement.py b/boolean_algebra/array_complement.py index 3293801980f4..d2ef12cae863 100644 --- a/boolean_algebra/array_complement.py +++ b/boolean_algebra/array_complement.py @@ -12,8 +12,8 @@ def array_complement(initial_lst: list, diff_lst: list) -> list: [] >>> array_complement([35], [36]) [35] - - + + """ return [c for c in initial_lst if c not in diff_lst]