From c9f8fa419a1f9ddba0798d4da48ed60aa2a847ab Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Sat, 14 Jan 2023 17:00:33 +0200 Subject: [PATCH 1/8] Fixed typos and applied code refactoring --- CHANGELOG.rst | 2 +- src/sequences/func.py | 3 --- tests/bisearch/conftest.py | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3f5effa..510e15b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -82,6 +82,6 @@ Tests are included as well. Warriors, Robbers and Wizards Game ================================== -Added the basic "wrw game" challenge description and implementation. This tasks +Added the basic "wrw game" challenge description and implementation. This task is considered to be the final exam for the OOP block. Tests are included as well. diff --git a/src/sequences/func.py b/src/sequences/func.py index efe14d9..e7cc226 100644 --- a/src/sequences/func.py +++ b/src/sequences/func.py @@ -134,9 +134,6 @@ def are_parentheses_balanced(origin: str) -> bool: return not parentheses_stack - - - def get_longest_uniq_length(origin: str) -> int: """Return the length of the longest on sequence of unique characters diff --git a/tests/bisearch/conftest.py b/tests/bisearch/conftest.py index 9460284..449f62f 100644 --- a/tests/bisearch/conftest.py +++ b/tests/bisearch/conftest.py @@ -16,6 +16,7 @@ def strings_large_fixture(): return fixture_file.read().splitlines() +# noinspection SpellCheckingInspection @pytest.fixture def find_all_fixture(): return ("ua", From eda04b43dfc827da93f8d83a2b1b77d20dfc522c Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Sat, 14 Jan 2023 18:19:36 +0200 Subject: [PATCH 2/8] Updated dependecies lock file --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 469dc9b..f3abe17 100644 --- a/poetry.lock +++ b/poetry.lock @@ -251,7 +251,7 @@ testing = ["covdefaults (>=2.2.2)", "importlib-metadata (>=5.1)", "pytest-cov (> [[package]] name = "pytest" -version = "7.2.0" +version = "7.2.1" description = "pytest: simple powerful testing with Python" category = "main" optional = false @@ -559,8 +559,8 @@ pyproject-api = [ {file = "pyproject_api-1.4.0.tar.gz", hash = "sha256:ac85c1f82e0291dbae5a7739dbb9a990e11ee4034c9b5599ea714f07a24ecd71"}, ] pytest = [ - {file = "pytest-7.2.0-py3-none-any.whl", hash = "sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71"}, - {file = "pytest-7.2.0.tar.gz", hash = "sha256:c4014eb40e10f11f355ad4e3c2fb2c6c6d1919c73f3b5a433de4708202cade59"}, + {file = "pytest-7.2.1-py3-none-any.whl", hash = "sha256:c7c6ca206e93355074ae32f7403e8ea12163b1163c976fee7d4d84027c162be5"}, + {file = "pytest-7.2.1.tar.gz", hash = "sha256:d45e0952f3727241918b8fd0f376f5ff6b301cc0777c6f9a556935c92d8a7d42"}, ] pytest-cov = [ {file = "pytest-cov-4.0.0.tar.gz", hash = "sha256:996b79efde6433cdbd0088872dbc5fb3ed7fe1578b68cdbba634f14bb8dd0470"}, From 7d63c261c2b9bddeea98e99370f377a81af07ae0 Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Tue, 24 Jan 2023 00:08:37 +0200 Subject: [PATCH 3/8] Removed docs section from readme file --- README.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.rst b/README.rst index d65dc60..7422ef0 100644 --- a/README.rst +++ b/README.rst @@ -81,7 +81,3 @@ There are two major directories: **src** and **tests**. Any useful code should be included to the source (src). Test cases for functions, classes etc. should lie inside of tests directory. It's ok to created nested packages within these directories if needed. - -The **docs** directory contains optional config for the documentation generator -and is used for documentation builds check only. The docs for this project are -to be generated within the main project and another configuration will be used. From 74e468957078e3546dc1c7cab094d599f57efc48 Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Tue, 24 Jan 2023 19:45:50 +0200 Subject: [PATCH 4/8] Added extra fibonacci functions --- src/calc/__init__.py | 1 + src/calc/func.py | 29 ++++++++++++++++++++++++- src/dynamic/tabulation.py | 37 ++++++++++++++++++++++++++------ tests/calc/func_test.py | 19 ++++++++++++++-- tests/dynamic/tabulation_test.py | 6 ++++++ 5 files changed, 82 insertions(+), 10 deletions(-) diff --git a/src/calc/__init__.py b/src/calc/__init__.py index 6284a9d..d4a59a7 100644 --- a/src/calc/__init__.py +++ b/src/calc/__init__.py @@ -7,6 +7,7 @@ __all__ = [ "get_factorial", "get_fibonacci_number", + "get_fibonacci_number_nr", "get_sum_of_strings", ] diff --git a/src/calc/func.py b/src/calc/func.py index c01390b..744fd44 100644 --- a/src/calc/func.py +++ b/src/calc/func.py @@ -57,12 +57,39 @@ def get_fibonacci_number(idx: int, /) -> int: if idx <= 0: return 0 - if 0 < idx < 3: # the same as ``idx == 1 or idx == 2`` + if idx <= 1: return 1 return get_fibonacci_number(idx - 1) + get_fibonacci_number(idx - 2) +def get_fibonacci_number_nr(idx: int, /) -> int: + """Return a Fibonacci's sequence number at a specified index + + :param idx: a Fibonacci sequence index starting from 0 + :type idx: int + + :return: a sequence's member + :rtype: int + + This function implements the non-recursive algorithm, which is more + efficient, since it does not have multiple recursive calls. + + """ + + if idx <= 0: + return 0 + + if idx <= 1: + return 1 + + previous, fib_number = 0, 1 + for _ in range(idx - 1): + previous, fib_number = fib_number, previous + fib_number + + return fib_number + + def get_sum_of_strings(number_1: str, number_2: str, /) -> str: """Return the sum of two numbers of string type as string diff --git a/src/dynamic/tabulation.py b/src/dynamic/tabulation.py index 749583a..1a31cb5 100644 --- a/src/dynamic/tabulation.py +++ b/src/dynamic/tabulation.py @@ -9,18 +9,41 @@ from calc.func import get_fibonacci_number as fib_classic +def get_fibonacci_sequence(size: int, /) -> List[int]: + """Return the Fibonacci numbers sequences of a given size + + :param size: the size of the requested sequence + :type size: int + + :return: the Fibonacci sequence + :rtype: list[int] + + The Fibonacci numbers (aka the Fibonacci sequence) is a sequence in + which each number is the sum of the two preceding onces. The sequence + commonly starts with 0 and 1. + + Usage examples: + + >>> assert get_fibonacci_sequence(0) == [] + >>> assert get_fibonacci_sequence(1) == [0] + >>> assert get_fibonacci_sequence(5) == [0, 1, 1, 2, 3] + >>> assert get_fibonacci_sequence(10) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] + + """ + + fibonacci: List[int] = [0, 1] + [0] * size + for idx in range(2, size): + fibonacci[idx] = fibonacci[idx - 1] + fibonacci[idx - 2] + + return fibonacci[:size] + + @functools.wraps(fib_classic, ("__annotations__", "__doc__")) def get_fibonacci_number(idx): # pylint:disable=C0116 if idx <= 0: return 0 - table: List[int] = [0, 1] + [0] * idx - - for i in range(idx): - table[i + 1] += table[i] - table[i + 2] += table[i] - - return table[idx] + return get_fibonacci_sequence(idx + 1)[idx] def get_grid_travels(height: int, width: int, /) -> int: diff --git a/tests/calc/func_test.py b/tests/calc/func_test.py index fba196a..08d1465 100644 --- a/tests/calc/func_test.py +++ b/tests/calc/func_test.py @@ -6,15 +6,30 @@ def test_get_factorial(): assert calc.get_factorial(5) == 120 -def test_fibonacci_number_getter(): - assert calc.get_fibonacci_number(-10) == 0 # special test case +def test_get_fibonacci_number(): + # test base cases + assert calc.get_fibonacci_number(-10) == 0 assert calc.get_fibonacci_number(0) == 0 assert calc.get_fibonacci_number(1) == 1 + # test custom cases assert calc.get_fibonacci_number(2) == 1 assert calc.get_fibonacci_number(3) == 2 assert calc.get_fibonacci_number(10) == 55 +def test_fibonacci_number_nr(): + # test base cases + assert calc.get_fibonacci_number_nr(-10) == 0 + assert calc.get_fibonacci_number_nr(0) == 0 + assert calc.get_fibonacci_number_nr(1) == 1 + assert calc.get_fibonacci_number_nr(2) == 1 + # test custom cases + assert calc.get_fibonacci_number_nr(3) == 2 + assert calc.get_fibonacci_number_nr(10) == 55 + assert calc.get_fibonacci_number_nr(50) == 12_586_269_025 + assert calc.get_fibonacci_number_nr(100) == 354_224_848_179_261_915_075 + + def test_sum_of_strings(): assert calc.get_sum_of_strings("123", "456") == "579" assert calc.get_sum_of_strings("123", "789") == "912" diff --git a/tests/dynamic/tabulation_test.py b/tests/dynamic/tabulation_test.py index 045f9e1..6b8be69 100644 --- a/tests/dynamic/tabulation_test.py +++ b/tests/dynamic/tabulation_test.py @@ -1,6 +1,12 @@ from dynamic import tabulation +def test_get_fibonacci_sequence(): + assert tabulation.get_fibonacci_sequence(0) == [] + assert tabulation.get_fibonacci_sequence(1) == [0] + assert tabulation.get_fibonacci_sequence(9) == [0, 1, 1, 2, 3, 5, 8, 13, 21] + + def test_get_fibonacci_number(): # test base cases assert tabulation.get_fibonacci_number(-10) == 0 From d956a0196cd8199f776eacf7bf024e0baa2a18db Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Tue, 24 Jan 2023 20:22:03 +0200 Subject: [PATCH 5/8] Updated docstrings --- src/primes/__init__.py | 2 +- src/primes/func.py | 19 ++++++ src/sorting/__init__.py | 2 +- src/sorting/func.py | 138 ++++++++++++++++++++++++++++------------ 4 files changed, 119 insertions(+), 42 deletions(-) diff --git a/src/primes/__init__.py b/src/primes/__init__.py index 62ca751..1fa33c5 100644 --- a/src/primes/__init__.py +++ b/src/primes/__init__.py @@ -30,4 +30,4 @@ "eratosthenes_sieve", ] -from .func import * +from primes.func import * diff --git a/src/primes/func.py b/src/primes/func.py index 441ca5f..e4c3c8e 100644 --- a/src/primes/func.py +++ b/src/primes/func.py @@ -19,6 +19,15 @@ def is_prime(number: int) -> bool: The result of this function is True if a number is prime, otherwise False. + Usage examples: + + >>> assert not is_prime(0) + >>> assert not is_prime(1) + >>> assert is_prime(2) + >>> assert is_prime(3) + >>> assert not is_prime(4) + >>> assert is_prime(5) + """ if number < 2: @@ -40,6 +49,11 @@ def get_primes(limit: int) -> List[int]: :return: the list of prime numbers within a specified range :rtype: list[int] + Usage examples: + + >>> assert get_primes(10) == [2, 3, 5, 7] + >>> assert get_primes(20) == [2, 3, 5, 7, 11, 13, 17, 19] + """ return [number for number in range(limit + 1) if is_prime(number)] @@ -72,6 +86,11 @@ def eratosthenes_sieve(limit: int) -> List[int]: .. seealso:: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes + Usage examples: + + >>> assert eratosthenes_sieve(10) == [2, 3, 5, 7] + >>> assert eratosthenes_sieve(20) == [2, 3, 5, 7, 11, 13, 17, 19] + """ sieve: List[bool] = [False, False] + [True] * limit diff --git a/src/sorting/__init__.py b/src/sorting/__init__.py index 0049e73..b8ceff1 100644 --- a/src/sorting/__init__.py +++ b/src/sorting/__init__.py @@ -67,4 +67,4 @@ "shell_sort" ] -from .func import * +from sorting.func import * diff --git a/src/sorting/func.py b/src/sorting/func.py index 99b7f2c..2755332 100644 --- a/src/sorting/func.py +++ b/src/sorting/func.py @@ -9,6 +9,12 @@ def bubble_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the bubble sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Bubble sort is a sorting algorithm that compares two adjacent elements and swaps them until they are not in the intended order. @@ -18,11 +24,10 @@ def bubble_sort(origin: List[int]) -> List[int]: .. seealso:: https://www.programiz.com/dsa/bubble-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> assert bubble_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> assert bubble_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -40,17 +45,23 @@ def bubble_sort(origin: List[int]) -> List[int]: def selection_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the selection sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + + Selection sort is a sorting algorithm that selects the smallest element from an unsorted list in each iteration and places that element at the beginning of the unsorted list. .. seealso:: https://www.programiz.com/dsa/selection-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> assert selection_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> assert selection_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -72,6 +83,12 @@ def selection_sort(origin: List[int]) -> List[int]: def insertion_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the insertion sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Insertion sort is a sorting algorithm that places an unsorted element at its suitable place in each iteration. @@ -85,11 +102,10 @@ def insertion_sort(origin: List[int]) -> List[int]: .. seealso:: https://www.programiz.com/dsa/insertion-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> assert insertion_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> assert insertion_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -120,6 +136,12 @@ def merge_lists(list_a: List[int], list_b: List[int]) -> List[int]: :return: merged sorted list :rtype: list[int] + Merge two lists that are already sorted into a new sorted list. + + Usage examples: + + >>> assert merge_lists([1, 3, 5], [2, 4]) == [1, 2, 3, 4, 5] + """ idx_a: int = 0 @@ -148,6 +170,13 @@ def merge_lists(list_a: List[int], list_b: List[int]) -> List[int]: def merge_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the merge sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + + Merge sort is one of the most popular sorting algorithms that is based on the principle of "Divide and Conquer Algorithm". @@ -157,11 +186,10 @@ def merge_sort(origin: List[int]) -> List[int]: .. seealso:: https://www.programiz.com/dsa/merge-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> merge_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> merge_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -179,6 +207,12 @@ def merge_sort(origin: List[int]) -> List[int]: def quick_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the quick sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Quicksort is a sorting algorithm based on the **divide and conquer approach** where: @@ -195,11 +229,10 @@ def quick_sort(origin: List[int]) -> List[int]: .. seealso:: https://www.programiz.com/dsa/quick-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> quick_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> quick_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -218,6 +251,12 @@ def quick_sort(origin: List[int]) -> List[int]: def counting_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the counting sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Counting sort is a sorting algorithm that sorts the elements of a list by counting the number of occurrences of each unique element in a list. The count is stored in an auxiliary list and the sorting @@ -225,11 +264,10 @@ def counting_sort(origin: List[int]) -> List[int]: .. seealso:: https://www.programiz.com/dsa/counting-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> counting_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> counting_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -293,6 +331,12 @@ def radix_counting(origin: List[int], places: int) -> List[int]: def radix_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the radix sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Radix sort is a sorting algorithm that sorts the elements by first grouping the individual digits of the same **place value**. Then, sort the elements according to their increasing/decreasing order. @@ -301,11 +345,10 @@ def radix_sort(origin: List[int]) -> List[int]: Then, we will sort elements based on the value of the tenth place. This process goes on until the last significant place. - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> assert radix_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> assert radix_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -323,6 +366,12 @@ def radix_sort(origin: List[int]) -> List[int]: def bucket_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the bucket sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Bucket sort is a sorting algorithm that divides the unsorted list elements into several groups called buckets. Each bucket is then sorted by using any of the suitable sorting algorithms or @@ -333,11 +382,10 @@ def bucket_sort(origin: List[int]) -> List[int]: .. seealso:: https://www.programiz.com/dsa/bucket-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> assert bucket_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> assert bubble_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -366,6 +414,12 @@ def bucket_sort(origin: List[int]) -> List[int]: def heap_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the heap sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Heap sort is a popular and efficient sorting algorithm in computer programming. Learning how to write the heap sort algorithm requires knowledge of two types of data structures - arrays and trees. @@ -375,11 +429,10 @@ def heap_sort(origin: List[int]) -> List[int]: .. seealso:: https://www.programiz.com/dsa/heap-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> heap_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> heap_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ @@ -417,17 +470,22 @@ def heapify(_ds: List[int], _size: int, _idx: int) -> List[int]: def shell_sort(origin: List[int]) -> List[int]: """Return a sorted collection using the shell sort algorithm + :param origin: an original list to sort + :type origin: list[int] + + :return: a sorted list + :rtype: list[int] + Shell sort is a generalized version of the insertion sort algorithm. It first sorts elements that are far apart from each other and successively reduces the interval between the elements to be sorted. .. seealso:: https://www.programiz.com/dsa/shell-sort - :param origin: an original list to sort - :type origin: list[int] + Usage examples: - :return: a sorted list - :rtype: list[int] + >>> assert shell_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] + >>> assert shell_sort([1, 5, 2, 4, 3]) == [1, 2, 3, 4, 5] """ From d83d849f2a0fd806013a00e7c1dcc336af201aab Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Tue, 24 Jan 2023 21:05:22 +0200 Subject: [PATCH 6/8] Support pip manager (#20) * Added pip manager support Added requirements file. Packages hashes are omitted to avoid issue with the newest pip version. Updated readme file with instruction on how to operate using pip. --- README.rst | 34 ++++++++++++++++++++++++++++------ requirements.txt | 29 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 requirements.txt diff --git a/README.rst b/README.rst index 7422ef0..cac5223 100644 --- a/README.rst +++ b/README.rst @@ -15,6 +15,11 @@ interview experience. Getting started =============== +This section describes the general usage of the project. + +Installing dependencies +----------------------- + It's recommended to use `poetry`_ with this project. Otherwise you are to do some additional work while installing dependencies and configuring internal packages. @@ -29,14 +34,31 @@ Once you've cloned the repository to your local machine install dependencies: This will also install internal packages for future tests. +PIP support +^^^^^^^^^^^ + +For whose, who prefer to use `pip`_ as a package manager, it's supported. +However it's not a primary package manager for this project, so problems may +still appear - please, report to bug tracker in case of any. + +You will need to install project dependencies and source code. +To do this use commands: + +.. code-block:: + + pip install -r requirements.txt + pip install -e . + +.. _pip: https://pip.pypa.io/ + Code health check ----------------- There are few dependencies installed to check the code health: -* pytest-cov -* mypy -* pylint +- pytest-cov +- mypy +- pylint They are acting as stand-alone commands, available from your terminal with poetry: @@ -53,11 +75,11 @@ Running tox `tox`_ aims to automate and standardize testing in Python. It is a generic virtualenv management and test command line tool you can use for: -* checking that your package installs correctly with different Python versions +- checking that your package installs correctly with different Python versions and interpreters -* running your tests in each of the environments, configuring your test tool of +- running your tests in each of the environments, configuring your test tool of choice -* acting as a frontend to Continuous Integration servers, greatly reducing +- acting as a frontend to Continuous Integration servers, greatly reducing boilerplate and merging CI and shell-based testing. .. _tox: https://tox.wiki diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..87d3733 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,29 @@ +astroid==2.13.2; python_full_version >= "3.7.2" +attrs==22.2.0; python_version >= "3.7" +cachetools==5.2.1; python_version >= "3.7" and python_version < "4.0" +chardet==5.1.0; python_version >= "3.7" +colorama==0.4.6; sys_platform == "win32" and python_full_version >= "3.7.2" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.7.0" and python_version >= "3.7") and (python_version >= "3.7" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.7" and python_full_version >= "3.7.0") +coverage==7.0.5; python_version >= "3.7" +dill==0.3.6 +distlib==0.3.6; python_version >= "3.7" +exceptiongroup==1.1.0; python_version < "3.11" and python_version >= "3.7" +filelock==3.9.0; python_version >= "3.7" +iniconfig==2.0.0; python_version >= "3.7" +isort==5.11.4; python_full_version >= "3.7.2" +lazy-object-proxy==1.9.0; python_version >= "3.7" and python_full_version >= "3.7.2" +mccabe==0.7.0; python_version >= "3.6" and python_full_version >= "3.7.2" +mypy-extensions==0.4.3; python_version >= "3.7" +mypy==0.991; python_version >= "3.7" +packaging==23.0; python_version >= "3.7" +platformdirs==2.6.2; python_version >= "3.7" and python_full_version >= "3.7.2" +pluggy==1.0.0; python_version >= "3.7" +pylint==2.15.10; python_full_version >= "3.7.2" +pyproject-api==1.4.0; python_version >= "3.7" +pytest-cov==4.0.0; python_version >= "3.6" +pytest==7.2.1; python_version >= "3.7" +tomli==2.0.1; python_version < "3.11" and python_version >= "3.7" and python_full_version >= "3.7.2" and python_full_version <= "3.11.0a6" +tomlkit==0.11.6; python_version >= "3.6" and python_full_version >= "3.7.2" +tox==4.2.8; python_version >= "3.7" +typing-extensions==4.4.0; python_version < "3.10" and python_full_version >= "3.7.2" and python_version >= "3.7" +virtualenv==20.17.1; python_version >= "3.7" +wrapt==1.14.1 From d3936e90e263082cdbc08243ba1834e3855d977a Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Tue, 31 Jan 2023 09:02:57 +0200 Subject: [PATCH 7/8] Brick wall challenge (#21) "Brick wall" is a basic-level challenge for working with data structures. The original challenge: https://leetcode.com/problems/brick-wall/ There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same. Draw a vertical line from the top to the bottom and cross the least bricks. If your line goes through the edge of a brick, then the brick is not considered as crossed. You cannot draw a line just along one of the two vertical edges of the wall, in which case the line will obviously cross no bricks. Given the 2D array wall that contains the information about the wall, return the minimum number of crossed bricks after drawing such a vertical line. --- poetry.lock | 144 ++++++++++++++++++------------------ pyproject.toml | 3 +- src/datasets/__init__.py | 15 ++++ src/datasets/func.py | 108 +++++++++++++++++++++++++++ src/datasets/py.typed | 0 tests/datasets/__init__.py | 0 tests/datasets/conftest.py | 38 ++++++++++ tests/datasets/func_test.py | 24 ++++++ 8 files changed, 259 insertions(+), 73 deletions(-) create mode 100644 src/datasets/__init__.py create mode 100644 src/datasets/func.py create mode 100644 src/datasets/py.typed create mode 100644 tests/datasets/__init__.py create mode 100644 tests/datasets/conftest.py create mode 100644 tests/datasets/func_test.py diff --git a/poetry.lock b/poetry.lock index f3abe17..2669322 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,6 +1,6 @@ [[package]] name = "astroid" -version = "2.13.2" +version = "2.13.3" description = "An abstract syntax tree for Python with inference support." category = "main" optional = false @@ -8,7 +8,7 @@ python-versions = ">=3.7.2" [package.dependencies] lazy-object-proxy = ">=1.4.0" -typing-extensions = ">=4.0.0" +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""} wrapt = [ {version = ">=1.11,<2", markers = "python_version < \"3.11\""}, {version = ">=1.14,<2", markers = "python_version >= \"3.11\""}, @@ -32,7 +32,7 @@ tests_no_zope = ["hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist", "c [[package]] name = "cachetools" -version = "5.2.1" +version = "5.3.0" description = "Extensible memoizing collections and decorators" category = "main" optional = false @@ -56,7 +56,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7 [[package]] name = "coverage" -version = "7.0.5" +version = "7.1.0" description = "Code coverage measurement for Python" category = "main" optional = false @@ -120,16 +120,16 @@ python-versions = ">=3.7" [[package]] name = "isort" -version = "5.11.4" +version = "5.12.0" description = "A Python utility / library to sort Python imports." category = "main" optional = false -python-versions = ">=3.7.0" +python-versions = ">=3.8.0" [package.extras] -colors = ["colorama (>=0.4.3,<0.5.0)"] +colors = ["colorama (>=0.4.3)"] requirements-deprecated-finder = ["pip-api", "pipreqs"] -pipfile-deprecated-finder = ["pipreqs", "requirementslib"] +pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] plugins = ["setuptools"] [[package]] @@ -235,7 +235,7 @@ testutils = ["gitpython (>3)"] [[package]] name = "pyproject-api" -version = "1.4.0" +version = "1.5.0" description = "API to interact with the python pyproject.toml based projects" category = "main" optional = false @@ -302,7 +302,7 @@ python-versions = ">=3.6" [[package]] name = "tox" -version = "4.2.8" +version = "4.4.3" description = "tox is a generic virtualenv management and test command line tool" category = "main" optional = false @@ -316,7 +316,7 @@ filelock = ">=3.9" packaging = ">=23" platformdirs = ">=2.6.2" pluggy = ">=1" -pyproject-api = ">=1.4" +pyproject-api = ">=1.5" tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} virtualenv = ">=20.17.1" @@ -364,16 +364,16 @@ content-hash = "e1b17f667cc28482e1dbff188939b02a4174798306ecd072167ae03e37337d28 [metadata.files] astroid = [ - {file = "astroid-2.13.2-py3-none-any.whl", hash = "sha256:8f6a8d40c4ad161d6fc419545ae4b2f275ed86d1c989c97825772120842ee0d2"}, - {file = "astroid-2.13.2.tar.gz", hash = "sha256:3bc7834720e1a24ca797fd785d77efb14f7a28ee8e635ef040b6e2d80ccb3303"}, + {file = "astroid-2.13.3-py3-none-any.whl", hash = "sha256:14c1603c41cc61aae731cad1884a073c4645e26f126d13ac8346113c95577f3b"}, + {file = "astroid-2.13.3.tar.gz", hash = "sha256:6afc22718a48a689ca24a97981ad377ba7fb78c133f40335dfd16772f29bcfb1"}, ] attrs = [ {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, ] cachetools = [ - {file = "cachetools-5.2.1-py3-none-any.whl", hash = "sha256:8462eebf3a6c15d25430a8c27c56ac61340b2ecf60c9ce57afc2b97e450e47da"}, - {file = "cachetools-5.2.1.tar.gz", hash = "sha256:5991bc0e08a1319bb618d3195ca5b6bc76646a49c21d55962977197b301cc1fe"}, + {file = "cachetools-5.3.0-py3-none-any.whl", hash = "sha256:429e1a1e845c008ea6c85aa35d4b98b65d6a9763eeef3e37e92728a12d1de9d4"}, + {file = "cachetools-5.3.0.tar.gz", hash = "sha256:13dfddc7b8df938c21a940dfa6557ce6e94a2f1cdfa58eb90c805721d58f2c14"}, ] chardet = [ {file = "chardet-5.1.0-py3-none-any.whl", hash = "sha256:362777fb014af596ad31334fde1e8c327dfdb076e1960d1694662d46a6917ab9"}, @@ -384,57 +384,57 @@ colorama = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] coverage = [ - {file = "coverage-7.0.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2a7f23bbaeb2a87f90f607730b45564076d870f1fb07b9318d0c21f36871932b"}, - {file = "coverage-7.0.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c18d47f314b950dbf24a41787ced1474e01ca816011925976d90a88b27c22b89"}, - {file = "coverage-7.0.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ef14d75d86f104f03dea66c13188487151760ef25dd6b2dbd541885185f05f40"}, - {file = "coverage-7.0.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:66e50680e888840c0995f2ad766e726ce71ca682e3c5f4eee82272c7671d38a2"}, - {file = "coverage-7.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9fed35ca8c6e946e877893bbac022e8563b94404a605af1d1e6accc7eb73289"}, - {file = "coverage-7.0.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d8d04e755934195bdc1db45ba9e040b8d20d046d04d6d77e71b3b34a8cc002d0"}, - {file = "coverage-7.0.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:7e109f1c9a3ece676597831874126555997c48f62bddbcace6ed17be3e372de8"}, - {file = "coverage-7.0.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0a1890fca2962c4f1ad16551d660b46ea77291fba2cc21c024cd527b9d9c8809"}, - {file = "coverage-7.0.5-cp310-cp310-win32.whl", hash = "sha256:be9fcf32c010da0ba40bf4ee01889d6c737658f4ddff160bd7eb9cac8f094b21"}, - {file = "coverage-7.0.5-cp310-cp310-win_amd64.whl", hash = "sha256:cbfcba14a3225b055a28b3199c3d81cd0ab37d2353ffd7f6fd64844cebab31ad"}, - {file = "coverage-7.0.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:30b5fec1d34cc932c1bc04017b538ce16bf84e239378b8f75220478645d11fca"}, - {file = "coverage-7.0.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1caed2367b32cc80a2b7f58a9f46658218a19c6cfe5bc234021966dc3daa01f0"}, - {file = "coverage-7.0.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d254666d29540a72d17cc0175746cfb03d5123db33e67d1020e42dae611dc196"}, - {file = "coverage-7.0.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:19245c249aa711d954623d94f23cc94c0fd65865661f20b7781210cb97c471c0"}, - {file = "coverage-7.0.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b05ed4b35bf6ee790832f68932baf1f00caa32283d66cc4d455c9e9d115aafc"}, - {file = "coverage-7.0.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:29de916ba1099ba2aab76aca101580006adfac5646de9b7c010a0f13867cba45"}, - {file = "coverage-7.0.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:e057e74e53db78122a3979f908973e171909a58ac20df05c33998d52e6d35757"}, - {file = "coverage-7.0.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:411d4ff9d041be08fdfc02adf62e89c735b9468f6d8f6427f8a14b6bb0a85095"}, - {file = "coverage-7.0.5-cp311-cp311-win32.whl", hash = "sha256:52ab14b9e09ce052237dfe12d6892dd39b0401690856bcfe75d5baba4bfe2831"}, - {file = "coverage-7.0.5-cp311-cp311-win_amd64.whl", hash = "sha256:1f66862d3a41674ebd8d1a7b6f5387fe5ce353f8719040a986551a545d7d83ea"}, - {file = "coverage-7.0.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b69522b168a6b64edf0c33ba53eac491c0a8f5cc94fa4337f9c6f4c8f2f5296c"}, - {file = "coverage-7.0.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:436e103950d05b7d7f55e39beeb4d5be298ca3e119e0589c0227e6d0b01ee8c7"}, - {file = "coverage-7.0.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b8c56bec53d6e3154eaff6ea941226e7bd7cc0d99f9b3756c2520fc7a94e6d96"}, - {file = "coverage-7.0.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a38362528a9115a4e276e65eeabf67dcfaf57698e17ae388599568a78dcb029"}, - {file = "coverage-7.0.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:f67472c09a0c7486e27f3275f617c964d25e35727af952869dd496b9b5b7f6a3"}, - {file = "coverage-7.0.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:220e3fa77d14c8a507b2d951e463b57a1f7810a6443a26f9b7591ef39047b1b2"}, - {file = "coverage-7.0.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:ecb0f73954892f98611e183f50acdc9e21a4653f294dfbe079da73c6378a6f47"}, - {file = "coverage-7.0.5-cp37-cp37m-win32.whl", hash = "sha256:d8f3e2e0a1d6777e58e834fd5a04657f66affa615dae61dd67c35d1568c38882"}, - {file = "coverage-7.0.5-cp37-cp37m-win_amd64.whl", hash = "sha256:9e662e6fc4f513b79da5d10a23edd2b87685815b337b1a30cd11307a6679148d"}, - {file = "coverage-7.0.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:790e4433962c9f454e213b21b0fd4b42310ade9c077e8edcb5113db0818450cb"}, - {file = "coverage-7.0.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:49640bda9bda35b057b0e65b7c43ba706fa2335c9a9896652aebe0fa399e80e6"}, - {file = "coverage-7.0.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d66187792bfe56f8c18ba986a0e4ae44856b1c645336bd2c776e3386da91e1dd"}, - {file = "coverage-7.0.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:276f4cd0001cd83b00817c8db76730938b1ee40f4993b6a905f40a7278103b3a"}, - {file = "coverage-7.0.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95304068686545aa368b35dfda1cdfbbdbe2f6fe43de4a2e9baa8ebd71be46e2"}, - {file = "coverage-7.0.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:17e01dd8666c445025c29684d4aabf5a90dc6ef1ab25328aa52bedaa95b65ad7"}, - {file = "coverage-7.0.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:ea76dbcad0b7b0deb265d8c36e0801abcddf6cc1395940a24e3595288b405ca0"}, - {file = "coverage-7.0.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:50a6adc2be8edd7ee67d1abc3cd20678987c7b9d79cd265de55941e3d0d56499"}, - {file = "coverage-7.0.5-cp38-cp38-win32.whl", hash = "sha256:e4ce984133b888cc3a46867c8b4372c7dee9cee300335e2925e197bcd45b9e16"}, - {file = "coverage-7.0.5-cp38-cp38-win_amd64.whl", hash = "sha256:4a950f83fd3f9bca23b77442f3a2b2ea4ac900944d8af9993743774c4fdc57af"}, - {file = "coverage-7.0.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3c2155943896ac78b9b0fd910fb381186d0c345911f5333ee46ac44c8f0e43ab"}, - {file = "coverage-7.0.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:54f7e9705e14b2c9f6abdeb127c390f679f6dbe64ba732788d3015f7f76ef637"}, - {file = "coverage-7.0.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ee30375b409d9a7ea0f30c50645d436b6f5dfee254edffd27e45a980ad2c7f4"}, - {file = "coverage-7.0.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b78729038abea6a5df0d2708dce21e82073463b2d79d10884d7d591e0f385ded"}, - {file = "coverage-7.0.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13250b1f0bd023e0c9f11838bdeb60214dd5b6aaf8e8d2f110c7e232a1bff83b"}, - {file = "coverage-7.0.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:2c407b1950b2d2ffa091f4e225ca19a66a9bd81222f27c56bd12658fc5ca1209"}, - {file = "coverage-7.0.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:c76a3075e96b9c9ff00df8b5f7f560f5634dffd1658bafb79eb2682867e94f78"}, - {file = "coverage-7.0.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:f26648e1b3b03b6022b48a9b910d0ae209e2d51f50441db5dce5b530fad6d9b1"}, - {file = "coverage-7.0.5-cp39-cp39-win32.whl", hash = "sha256:ba3027deb7abf02859aca49c865ece538aee56dcb4871b4cced23ba4d5088904"}, - {file = "coverage-7.0.5-cp39-cp39-win_amd64.whl", hash = "sha256:949844af60ee96a376aac1ded2a27e134b8c8d35cc006a52903fc06c24a3296f"}, - {file = "coverage-7.0.5-pp37.pp38.pp39-none-any.whl", hash = "sha256:b9727ac4f5cf2cbf87880a63870b5b9730a8ae3a4a360241a0fdaa2f71240ff0"}, - {file = "coverage-7.0.5.tar.gz", hash = "sha256:051afcbd6d2ac39298d62d340f94dbb6a1f31de06dfaf6fcef7b759dd3860c45"}, + {file = "coverage-7.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:3b946bbcd5a8231383450b195cfb58cb01cbe7f8949f5758566b881df4b33baf"}, + {file = "coverage-7.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ec8e767f13be637d056f7e07e61d089e555f719b387a7070154ad80a0ff31801"}, + {file = "coverage-7.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d4a5a5879a939cb84959d86869132b00176197ca561c664fc21478c1eee60d75"}, + {file = "coverage-7.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b643cb30821e7570c0aaf54feaf0bfb630b79059f85741843e9dc23f33aaca2c"}, + {file = "coverage-7.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:32df215215f3af2c1617a55dbdfb403b772d463d54d219985ac7cd3bf124cada"}, + {file = "coverage-7.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:33d1ae9d4079e05ac4cc1ef9e20c648f5afabf1a92adfaf2ccf509c50b85717f"}, + {file = "coverage-7.1.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:29571503c37f2ef2138a306d23e7270687c0efb9cab4bd8038d609b5c2393a3a"}, + {file = "coverage-7.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:63ffd21aa133ff48c4dff7adcc46b7ec8b565491bfc371212122dd999812ea1c"}, + {file = "coverage-7.1.0-cp310-cp310-win32.whl", hash = "sha256:4b14d5e09c656de5038a3f9bfe5228f53439282abcab87317c9f7f1acb280352"}, + {file = "coverage-7.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:8361be1c2c073919500b6601220a6f2f98ea0b6d2fec5014c1d9cfa23dd07038"}, + {file = "coverage-7.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:da9b41d4539eefd408c46725fb76ecba3a50a3367cafb7dea5f250d0653c1040"}, + {file = "coverage-7.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c5b15ed7644ae4bee0ecf74fee95808dcc34ba6ace87e8dfbf5cb0dc20eab45a"}, + {file = "coverage-7.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d12d076582507ea460ea2a89a8c85cb558f83406c8a41dd641d7be9a32e1274f"}, + {file = "coverage-7.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e2617759031dae1bf183c16cef8fcfb3de7617f394c813fa5e8e46e9b82d4222"}, + {file = "coverage-7.1.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c4e4881fa9e9667afcc742f0c244d9364d197490fbc91d12ac3b5de0bf2df146"}, + {file = "coverage-7.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:9d58885215094ab4a86a6aef044e42994a2bd76a446dc59b352622655ba6621b"}, + {file = "coverage-7.1.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:ffeeb38ee4a80a30a6877c5c4c359e5498eec095878f1581453202bfacc8fbc2"}, + {file = "coverage-7.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3baf5f126f30781b5e93dbefcc8271cb2491647f8283f20ac54d12161dff080e"}, + {file = "coverage-7.1.0-cp311-cp311-win32.whl", hash = "sha256:ded59300d6330be27bc6cf0b74b89ada58069ced87c48eaf9344e5e84b0072f7"}, + {file = "coverage-7.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:6a43c7823cd7427b4ed763aa7fb63901ca8288591323b58c9cd6ec31ad910f3c"}, + {file = "coverage-7.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7a726d742816cb3a8973c8c9a97539c734b3a309345236cd533c4883dda05b8d"}, + {file = "coverage-7.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bc7c85a150501286f8b56bd8ed3aa4093f4b88fb68c0843d21ff9656f0009d6a"}, + {file = "coverage-7.1.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f5b4198d85a3755d27e64c52f8c95d6333119e49fd001ae5798dac872c95e0f8"}, + {file = "coverage-7.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ddb726cb861c3117a553f940372a495fe1078249ff5f8a5478c0576c7be12050"}, + {file = "coverage-7.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:51b236e764840a6df0661b67e50697aaa0e7d4124ca95e5058fa3d7cbc240b7c"}, + {file = "coverage-7.1.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:7ee5c9bb51695f80878faaa5598040dd6c9e172ddcf490382e8aedb8ec3fec8d"}, + {file = "coverage-7.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c31b75ae466c053a98bf26843563b3b3517b8f37da4d47b1c582fdc703112bc3"}, + {file = "coverage-7.1.0-cp37-cp37m-win32.whl", hash = "sha256:3b155caf3760408d1cb903b21e6a97ad4e2bdad43cbc265e3ce0afb8e0057e73"}, + {file = "coverage-7.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:2a60d6513781e87047c3e630b33b4d1e89f39836dac6e069ffee28c4786715f5"}, + {file = "coverage-7.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f2cba5c6db29ce991029b5e4ac51eb36774458f0a3b8d3137241b32d1bb91f06"}, + {file = "coverage-7.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:beeb129cacea34490ffd4d6153af70509aa3cda20fdda2ea1a2be870dfec8d52"}, + {file = "coverage-7.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0c45948f613d5d18c9ec5eaa203ce06a653334cf1bd47c783a12d0dd4fd9c851"}, + {file = "coverage-7.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ef382417db92ba23dfb5864a3fc9be27ea4894e86620d342a116b243ade5d35d"}, + {file = "coverage-7.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7c7c0d0827e853315c9bbd43c1162c006dd808dbbe297db7ae66cd17b07830f0"}, + {file = "coverage-7.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:e5cdbb5cafcedea04924568d990e20ce7f1945a1dd54b560f879ee2d57226912"}, + {file = "coverage-7.1.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:9817733f0d3ea91bea80de0f79ef971ae94f81ca52f9b66500c6a2fea8e4b4f8"}, + {file = "coverage-7.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:218fe982371ac7387304153ecd51205f14e9d731b34fb0568181abaf7b443ba0"}, + {file = "coverage-7.1.0-cp38-cp38-win32.whl", hash = "sha256:04481245ef966fbd24ae9b9e537ce899ae584d521dfbe78f89cad003c38ca2ab"}, + {file = "coverage-7.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:8ae125d1134bf236acba8b83e74c603d1b30e207266121e76484562bc816344c"}, + {file = "coverage-7.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2bf1d5f2084c3932b56b962a683074a3692bce7cabd3aa023c987a2a8e7612f6"}, + {file = "coverage-7.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:98b85dd86514d889a2e3dd22ab3c18c9d0019e696478391d86708b805f4ea0fa"}, + {file = "coverage-7.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:38da2db80cc505a611938d8624801158e409928b136c8916cd2e203970dde4dc"}, + {file = "coverage-7.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3164d31078fa9efe406e198aecd2a02d32a62fecbdef74f76dad6a46c7e48311"}, + {file = "coverage-7.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db61a79c07331e88b9a9974815c075fbd812bc9dbc4dc44b366b5368a2936063"}, + {file = "coverage-7.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9ccb092c9ede70b2517a57382a601619d20981f56f440eae7e4d7eaafd1d1d09"}, + {file = "coverage-7.1.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:33ff26d0f6cc3ca8de13d14fde1ff8efe1456b53e3f0273e63cc8b3c84a063d8"}, + {file = "coverage-7.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d47dd659a4ee952e90dc56c97d78132573dc5c7b09d61b416a9deef4ebe01a0c"}, + {file = "coverage-7.1.0-cp39-cp39-win32.whl", hash = "sha256:d248cd4a92065a4d4543b8331660121b31c4148dd00a691bfb7a5cdc7483cfa4"}, + {file = "coverage-7.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:7ed681b0f8e8bcbbffa58ba26fcf5dbc8f79e7997595bf071ed5430d8c08d6f3"}, + {file = "coverage-7.1.0-pp37.pp38.pp39-none-any.whl", hash = "sha256:755e89e32376c850f826c425ece2c35a4fc266c081490eb0a841e7c1cb0d3bda"}, + {file = "coverage-7.1.0.tar.gz", hash = "sha256:10188fe543560ec4874f974b5305cd1a8bdcfa885ee00ea3a03733464c4ca265"}, ] dill = [ {file = "dill-0.3.6-py3-none-any.whl", hash = "sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0"}, @@ -457,8 +457,8 @@ iniconfig = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] isort = [ - {file = "isort-5.11.4-py3-none-any.whl", hash = "sha256:c033fd0edb91000a7f09527fe5c75321878f98322a77ddcc81adbd83724afb7b"}, - {file = "isort-5.11.4.tar.gz", hash = "sha256:6db30c5ded9815d813932c04c2f85a360bcdd35fed496f4d8f35495ef0a261b6"}, + {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, + {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, ] lazy-object-proxy = [ {file = "lazy-object-proxy-1.9.0.tar.gz", hash = "sha256:659fb5809fa4629b8a1ac5106f669cfc7bef26fbb389dda53b3e010d1ac4ebae"}, @@ -555,8 +555,8 @@ pylint = [ {file = "pylint-2.15.10.tar.gz", hash = "sha256:b3dc5ef7d33858f297ac0d06cc73862f01e4f2e74025ec3eff347ce0bc60baf5"}, ] pyproject-api = [ - {file = "pyproject_api-1.4.0-py3-none-any.whl", hash = "sha256:c34226297781efdd1ba4dfb74ce21076d9a8360e2125ea31803c1a02c76b2460"}, - {file = "pyproject_api-1.4.0.tar.gz", hash = "sha256:ac85c1f82e0291dbae5a7739dbb9a990e11ee4034c9b5599ea714f07a24ecd71"}, + {file = "pyproject_api-1.5.0-py3-none-any.whl", hash = "sha256:4c111277dfb96bcd562c6245428f27250b794bfe3e210b8714c4f893952f2c17"}, + {file = "pyproject_api-1.5.0.tar.gz", hash = "sha256:0962df21f3e633b8ddb9567c011e6c1b3dcdfc31b7860c0ede7e24c5a1200fbe"}, ] pytest = [ {file = "pytest-7.2.1-py3-none-any.whl", hash = "sha256:c7c6ca206e93355074ae32f7403e8ea12163b1163c976fee7d4d84027c162be5"}, @@ -575,8 +575,8 @@ tomlkit = [ {file = "tomlkit-0.11.6.tar.gz", hash = "sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"}, ] tox = [ - {file = "tox-4.2.8-py3-none-any.whl", hash = "sha256:e9d5006a533d280e2ca26e3ca61052ffa55a65b683486f92d12563a14a9b7a4f"}, - {file = "tox-4.2.8.tar.gz", hash = "sha256:7c31940d755355210151e8bef23feab3d714a8a4795e513c454ff0baccd995b1"}, + {file = "tox-4.4.3-py3-none-any.whl", hash = "sha256:04ad250ceff5ca4b6b7c62b8f7839fbbde8fd656d037756c9387eec6d643a7d8"}, + {file = "tox-4.4.3.tar.gz", hash = "sha256:2ae0ab67b0c4ca0fc3da0a8814f88ee6a94b43f5c911258c9b78e8b40591ed2b"}, ] typing-extensions = [ {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, diff --git a/pyproject.toml b/pyproject.toml index 03b0575..a257e20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,11 +35,12 @@ packages = [ { include = "bisearch", from = "src" }, { include = "calc", from = "src" }, { include = "conv_store", from = "src" }, + { include = "datasets", from = "src" }, { include = "dynamic", from = "src" }, { include = "sequences", from = "src" }, { include = "sorting", from = "src" }, { include = "primes", from = "src" }, - { include = "wrw_game", from = "src" } + { include = "wrw_game", from = "src" }, ] [tool.poetry.dependencies] diff --git a/src/datasets/__init__.py b/src/datasets/__init__.py new file mode 100644 index 0000000..6a3ec92 --- /dev/null +++ b/src/datasets/__init__.py @@ -0,0 +1,15 @@ +""" +Dataset challenges +================== + +""" + +__all__ = [ + "get_bricks_count", + "get_position_frequency", + "get_least_bricks_position", + "get_least_bricks_count", +] + +from datasets.func import (get_bricks_count, get_least_bricks_count, + get_least_bricks_position, get_position_frequency) diff --git a/src/datasets/func.py b/src/datasets/func.py new file mode 100644 index 0000000..7879a9a --- /dev/null +++ b/src/datasets/func.py @@ -0,0 +1,108 @@ +""" +Datasets functions implementation + +""" + +from typing import Dict, List + + +# brick wall challenge +def get_bricks_count(structure: List[List[int]]) -> int: + """Return number of bricks in the wall structure + + :param structure: represents wall structure as sequences of integers + :type structure: list[list[int]] + + :return: total number of bricks in the entire wall structure + :rtype: int + + Usage: + + >>> get_bricks_count([[1], [1], [1]]) == 3 + >>> get_bricks_count([[1, 1, 1], [1, 1, 1]]) == 6 + >>> get_bricks_count([[2, 1, 2], [1, 1, 1, 1, 1]]) == 8 + + """ + + return sum(len(row) for row in structure) + + +def get_position_frequency(structure: List[List[int]]) -> Dict[int, int]: + """Return a matrix of position-bricks pairs for a structure + + :param structure: represents wall structure as sequences of integers + :type structure: list[list[int]] + + :return: the position - frequency matrix + :rtype: dict[int, int] + + Usage: + + >>> assert get_position_frequency([[1], [1], [1]]) == {} + >>> assert get_position_frequency([[1, 2], [2, 1], [3]]) = {1: 1, 2: 1} + >>> assert get_position_frequency([[1, 1, 1], [1, 1, 1]]) = {1: 2, 2: 2} + + """ + + structure_matrix = {} + + for row in structure: + row_length = 0 + for brick_length in row[:-1]: + row_length += brick_length + if row_length not in structure_matrix: + structure_matrix[row_length] = 0 + structure_matrix[row_length] += 1 + + return structure_matrix + + +def get_least_bricks_position(structure: List[List[int]]) -> int: + """Return a pointer to the weakest line in the structure + + :param structure: represents wall structure as sequences of integers + :type structure: list[list[int]] + + :return: the distance from the left edge to the weakest line location + :rtype: int + + This function uses helper function ``get_structure_matrix`` to build + the matrix of distances from the left edge of the "wall". + + Usage: + + >>> assert get_least_bricks_position([[1], [1], [1]]) == 0 + >>> assert get_least_bricks_position([[1, 1, 1], [1, 1, 1]]) == 1 + + """ + + matrix = get_position_frequency(structure) + if not matrix: + return 0 + + return max(matrix, key=matrix.get) # type: ignore + + +def get_least_bricks_count(structure: List[List[int]]) -> int: + """Return the least number of bricks in a vertical line + + :param structure: represents wall structure as sequences of integers + :type structure: list[list[int]] + + :return: minimum number of bricks in a line + :rtype: int + + Usage: + + >>> assert get_least_bricks_count([[1], [1], [1]]) == 3 + >>> assert get_least_bricks_count([[1, 2], [2, 1], [3], [1, 1, 1]]) == 2 + >>> assert get_least_bricks_count([[1, 1, 1], [1, 1, 1]]) == 0 + + """ + + max_value: int = 0 + matrix = get_position_frequency(structure) + for count in matrix.values(): + max_value = max(max_value, count) + + return len(structure) - max_value diff --git a/src/datasets/py.typed b/src/datasets/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/tests/datasets/__init__.py b/tests/datasets/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/datasets/conftest.py b/tests/datasets/conftest.py new file mode 100644 index 0000000..ab91032 --- /dev/null +++ b/tests/datasets/conftest.py @@ -0,0 +1,38 @@ +import pytest + + +@pytest.fixture +def small_bricks_wall(): + return [[1], [1], [1]] + + +@pytest.fixture +def bricks_wall(): + return [ + [5, 5, 3, 4, 1], + [3, 2, 1, 4, 2, 1, 5], + [2, 3, 1, 5, 5, 2], + [3, 4, 3, 4, 3, 1], + [5, 5, 3, 2, 3], + ] + + +@pytest.fixture +def matrix(): + return {5: 4, 10: 4, 13: 3, 17: 2, 3: 2, 6: 2, 12: 1, 2: 1, 11: 1, 16: 1, + 7: 1, 14: 1, 15: 1} + + +@pytest.fixture +def position(): + return 5 + + +@pytest.fixture +def bricks_count(): + return 29 + + +@pytest.fixture +def least_bricks(): + return 1 diff --git a/tests/datasets/func_test.py b/tests/datasets/func_test.py new file mode 100644 index 0000000..fed8893 --- /dev/null +++ b/tests/datasets/func_test.py @@ -0,0 +1,24 @@ +import datasets + + +def test_brick_counter(bricks_wall, bricks_count): + assert datasets.get_bricks_count(bricks_wall) == bricks_count + + +def test_matrix_builder(bricks_wall, position): + assert datasets.get_least_bricks_position(bricks_wall) == position + + +def test_least_bricks(bricks_wall, small_bricks_wall): + assert datasets.get_least_bricks_count(bricks_wall) == 1 + assert datasets.get_least_bricks_count(small_bricks_wall) == 3 + + +def test_original_case(): + wall = [[1, 2, 2, 1], + [3, 1, 2], + [1, 3, 2], + [2, 4], + [3, 1, 2], + [1, 3, 1, 1]] + assert datasets.get_least_bricks_count(wall) == 2 From 747f1c6d4afe09d90dfa6c1ee91447abc51f6f14 Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Tue, 31 Jan 2023 09:19:59 +0200 Subject: [PATCH 8/8] Prepared release 2023.01.2 Updated project dependencies. From this moment all dependencies are dev-only. --- CHANGELOG.rst | 19 +++++++++++++++ poetry.lock | 60 ++++++++++++++++++++++++------------------------ pyproject.toml | 14 +++++++---- requirements.txt | 12 +++++----- 4 files changed, 64 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 510e15b..8db9a6a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,22 @@ +################# +Release 2023.01.2 +################# + +******************** +Brick Wall Challenge +******************** + +Added brick wall challenge. Original problem set is published at: +https://leetcode.com/problems/brick-wall/ + +************** +Project Itself +************** + +- Moved project dependencies to dev-section. Project has dev-deps only. +- From now pip package manage is supported as well. +- Removed legacy documentation section from README + ############### Release 2023-01 ############### diff --git a/poetry.lock b/poetry.lock index 2669322..6395683 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,7 +2,7 @@ name = "astroid" version = "2.13.3" description = "An abstract syntax tree for Python with inference support." -category = "main" +category = "dev" optional = false python-versions = ">=3.7.2" @@ -18,7 +18,7 @@ wrapt = [ name = "attrs" version = "22.2.0" description = "Classes Without Boilerplate" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -34,7 +34,7 @@ tests_no_zope = ["hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist", "c name = "cachetools" version = "5.3.0" description = "Extensible memoizing collections and decorators" -category = "main" +category = "dev" optional = false python-versions = "~=3.7" @@ -42,7 +42,7 @@ python-versions = "~=3.7" name = "chardet" version = "5.1.0" description = "Universal encoding detector for Python 3" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -50,7 +50,7 @@ python-versions = ">=3.7" name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "main" +category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" @@ -58,7 +58,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7 name = "coverage" version = "7.1.0" description = "Code coverage measurement for Python" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -72,7 +72,7 @@ toml = ["tomli"] name = "dill" version = "0.3.6" description = "serialize all of python" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -83,7 +83,7 @@ graph = ["objgraph (>=1.7.2)"] name = "distlib" version = "0.3.6" description = "Distribution utilities" -category = "main" +category = "dev" optional = false python-versions = "*" @@ -91,7 +91,7 @@ python-versions = "*" name = "exceptiongroup" version = "1.1.0" description = "Backport of PEP 654 (exception groups)" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -102,7 +102,7 @@ test = ["pytest (>=6)"] name = "filelock" version = "3.9.0" description = "A platform independent file lock." -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -114,7 +114,7 @@ testing = ["covdefaults (>=2.2.2)", "coverage (>=7.0.1)", "pytest-cov (>=4)", "p name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -122,7 +122,7 @@ python-versions = ">=3.7" name = "isort" version = "5.12.0" description = "A Python utility / library to sort Python imports." -category = "main" +category = "dev" optional = false python-versions = ">=3.8.0" @@ -136,7 +136,7 @@ plugins = ["setuptools"] name = "lazy-object-proxy" version = "1.9.0" description = "A fast and thorough lazy object proxy." -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -144,7 +144,7 @@ python-versions = ">=3.7" name = "mccabe" version = "0.7.0" description = "McCabe checker, plugin for flake8" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -152,7 +152,7 @@ python-versions = ">=3.6" name = "mypy" version = "0.991" description = "Optional static typing for Python" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -171,7 +171,7 @@ reports = ["lxml"] name = "mypy-extensions" version = "0.4.3" description = "Experimental type system extensions for programs checked with the mypy typechecker." -category = "main" +category = "dev" optional = false python-versions = "*" @@ -179,7 +179,7 @@ python-versions = "*" name = "packaging" version = "23.0" description = "Core utilities for Python packages" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -187,7 +187,7 @@ python-versions = ">=3.7" name = "platformdirs" version = "2.6.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -199,7 +199,7 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest-cov (>=4)", "pytes name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -211,7 +211,7 @@ dev = ["tox", "pre-commit"] name = "pylint" version = "2.15.10" description = "python code static checker" -category = "main" +category = "dev" optional = false python-versions = ">=3.7.2" @@ -237,7 +237,7 @@ testutils = ["gitpython (>3)"] name = "pyproject-api" version = "1.5.0" description = "API to interact with the python pyproject.toml based projects" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -253,7 +253,7 @@ testing = ["covdefaults (>=2.2.2)", "importlib-metadata (>=5.1)", "pytest-cov (> name = "pytest" version = "7.2.1" description = "pytest: simple powerful testing with Python" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -273,7 +273,7 @@ testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2. name = "pytest-cov" version = "4.0.0" description = "Pytest plugin for measuring coverage." -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -288,7 +288,7 @@ testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtuale name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -296,7 +296,7 @@ python-versions = ">=3.7" name = "tomlkit" version = "0.11.6" description = "Style preserving TOML library" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -304,7 +304,7 @@ python-versions = ">=3.6" name = "tox" version = "4.4.3" description = "tox is a generic virtualenv management and test command line tool" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -328,7 +328,7 @@ testing = ["build[virtualenv] (>=0.9)", "covdefaults (>=2.2.2)", "devpi-process name = "typing-extensions" version = "4.4.0" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" @@ -336,7 +336,7 @@ python-versions = ">=3.7" name = "virtualenv" version = "20.17.1" description = "Virtual Python Environment builder" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -353,14 +353,14 @@ testing = ["coverage (>=6.2)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7 name = "wrapt" version = "1.14.1" description = "Module for decorators, wrappers and monkey patching." -category = "main" +category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "e1b17f667cc28482e1dbff188939b02a4174798306ecd072167ae03e37337d28" +content-hash = "1f561c9c06faf8af24dc0205996f895e12e80d1effc63b66d6a331b59c435735" [metadata.files] astroid = [ diff --git a/pyproject.toml b/pyproject.toml index a257e20..68b8600 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "problem-sets" -version = "2022.11.dev" -description = "python training course - problem sets" +version = "2023.01.1" +description = "Challenges and solutions for the Python training course" license = "MIT" authors = [ "Serhii Horodilov " @@ -20,7 +20,11 @@ keywords = [ "challenge", "educational", "tutorial", - "training" + "training", + "basic", + "oop", + "dynamic", + "programming", ] classifiers = [ "License :: OSI Approved :: MIT License", @@ -45,13 +49,13 @@ packages = [ [tool.poetry.dependencies] python = "^3.9" + +[tool.poetry.dev-dependencies] pytest-cov = "^4.0.0" mypy = "^0.991" pylint = "^2.15.5" tox = "^4.0" -[tool.poetry.dev-dependencies] - [tool.poetry.scripts] wrw_game = "wrw_game.__main__:run" diff --git a/requirements.txt b/requirements.txt index 87d3733..83a4eee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,15 @@ -astroid==2.13.2; python_full_version >= "3.7.2" +astroid==2.13.3; python_full_version >= "3.7.2" attrs==22.2.0; python_version >= "3.7" -cachetools==5.2.1; python_version >= "3.7" and python_version < "4.0" +cachetools==5.3.0; python_version >= "3.7" and python_version < "4.0" chardet==5.1.0; python_version >= "3.7" colorama==0.4.6; sys_platform == "win32" and python_full_version >= "3.7.2" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.7.0" and python_version >= "3.7") and (python_version >= "3.7" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.7" and python_full_version >= "3.7.0") -coverage==7.0.5; python_version >= "3.7" +coverage==7.1.0; python_version >= "3.7" dill==0.3.6 distlib==0.3.6; python_version >= "3.7" exceptiongroup==1.1.0; python_version < "3.11" and python_version >= "3.7" filelock==3.9.0; python_version >= "3.7" iniconfig==2.0.0; python_version >= "3.7" -isort==5.11.4; python_full_version >= "3.7.2" +isort==5.12.0; python_full_version >= "3.8.0" lazy-object-proxy==1.9.0; python_version >= "3.7" and python_full_version >= "3.7.2" mccabe==0.7.0; python_version >= "3.6" and python_full_version >= "3.7.2" mypy-extensions==0.4.3; python_version >= "3.7" @@ -18,12 +18,12 @@ packaging==23.0; python_version >= "3.7" platformdirs==2.6.2; python_version >= "3.7" and python_full_version >= "3.7.2" pluggy==1.0.0; python_version >= "3.7" pylint==2.15.10; python_full_version >= "3.7.2" -pyproject-api==1.4.0; python_version >= "3.7" +pyproject-api==1.5.0; python_version >= "3.7" pytest-cov==4.0.0; python_version >= "3.6" pytest==7.2.1; python_version >= "3.7" tomli==2.0.1; python_version < "3.11" and python_version >= "3.7" and python_full_version >= "3.7.2" and python_full_version <= "3.11.0a6" tomlkit==0.11.6; python_version >= "3.6" and python_full_version >= "3.7.2" -tox==4.2.8; python_version >= "3.7" +tox==4.4.3; python_version >= "3.7" typing-extensions==4.4.0; python_version < "3.10" and python_full_version >= "3.7.2" and python_version >= "3.7" virtualenv==20.17.1; python_version >= "3.7" wrapt==1.14.1