From ebd2f27245c286edb2c508ca87b0dd5e9eabbcb6 Mon Sep 17 00:00:00 2001 From: Elizaveta Menshikova Date: Fri, 7 Nov 2025 15:30:16 +0300 Subject: [PATCH 1/8] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d564eb6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Elizaveta Menshikova + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 6c049f1e9cf29688c3431b10ef85cd2079bdc546 Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Fri, 7 Nov 2025 12:41:10 +0000 Subject: [PATCH 2/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d0c924 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Python +__pycache__/ +*.pyc +*.pyo +*.pyd +*.so + +# Virtual environments +venv/ +env/ +.venv/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Testing +.pytest_cache/ +.coverage +htmlcov/ + +# Project-specific +*.log +temp/ +tmp/ From 9e17052ad92cb19618a732d7f01d723eb1b4aab0 Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Fri, 7 Nov 2025 12:47:01 +0000 Subject: [PATCH 3/8] =?UTF-8?q?=D0=92=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B5=20t?= =?UTF-8?q?ests.yml=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=203.13=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B03.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d09842c..5908b8f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.13" + python-version: "3.12" - name: Install dependencies run: | From 211a9c6f56d29b60a4f3e5788dc7404f014f670e Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Fri, 7 Nov 2025 13:17:13 +0000 Subject: [PATCH 4/8] =?UTF-8?q?=D0=A3=D1=87=D1=82=D0=B5=D0=BD=20=D1=81?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D0=B0=D0=B9=20=D0=BD=D0=B5=D1=81=D0=BE=D1=80?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin_search.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin_search.py b/src/bin_search.py index 713abfc..6e18444 100644 --- a/src/bin_search.py +++ b/src/bin_search.py @@ -1,4 +1,6 @@ def binSearch(xs: list[int], x: int): + if xs != sorted(xs): + raise ValueError("Массив не отсортирован") left, right = 0, len(xs) - 1 while left < right: mid = (left + right) // 2 From c566f98e4d0d136a5c56f9d96c914fc6301f4980 Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Fri, 7 Nov 2025 13:30:56 +0000 Subject: [PATCH 5/8] =?UTF-8?q?=D0=A3=D1=87=D1=82=D0=B5=D0=BD=20=D1=81?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D0=B0=D0=B9=20,=20=D0=BA=D0=BE=D0=B3=D0=B4?= =?UTF-8?q?=D0=B0=20left=20=3D=3D=20right?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin_search.py b/src/bin_search.py index 6e18444..81a158d 100644 --- a/src/bin_search.py +++ b/src/bin_search.py @@ -2,7 +2,7 @@ def binSearch(xs: list[int], x: int): if xs != sorted(xs): raise ValueError("Массив не отсортирован") left, right = 0, len(xs) - 1 - while left < right: + while left <= right: mid = (left + right) // 2 if xs[mid] == x: return mid From 8fd3c97dc8b0a7a9d6e0fc1a41cedbf69a1d2c90 Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Fri, 7 Nov 2025 13:43:38 +0000 Subject: [PATCH 6/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5,=20=D0=BA=D0=BE=D0=B3=D0=B4=D0=B0=20=D1=8D=D0=BB?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=20=D0=BE=D1=82=D1=81=D1=83=D1=82?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D1=83=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin_search.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin_search.py b/src/bin_search.py index 81a158d..c55ccbb 100644 --- a/src/bin_search.py +++ b/src/bin_search.py @@ -1,4 +1,6 @@ def binSearch(xs: list[int], x: int): + if x not in xs: + raise ValueError("такого элемента нет") if xs != sorted(xs): raise ValueError("Массив не отсортирован") left, right = 0, len(xs) - 1 From 7941485b2042979d5ce77259bf324aa11836e72c Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Fri, 7 Nov 2025 13:49:20 +0000 Subject: [PATCH 7/8] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20import=20pytest=20,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=D0=BE=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D1=8F=D0=BC=D0=B8?= =?UTF-8?q?=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_bin_searh.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_bin_searh.py b/test/test_bin_searh.py index d18d85b..9ad49cd 100644 --- a/test/test_bin_searh.py +++ b/test/test_bin_searh.py @@ -1,3 +1,4 @@ +import pytest from src.bin_search import binSearch @@ -11,3 +12,13 @@ def test_start(): def test_not_in_list(): assert binSearch([1, 2, 3, 4], 5) == -1 + + +def test_unsorted(): + with pytest.raises(ValueError, match="Массив не отсортирован"): + binSearch([8, 3, 6, 1], 6) + + +def test_unsorted(): + with pytest.raises(ValueError, match="такого элемента нет"): + binSearch([1, 2, 3], 9) From 8a703dd43edf9b79e203aae651c55c959d691bd3 Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Fri, 7 Nov 2025 13:56:59 +0000 Subject: [PATCH 8/8] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20import=20pytest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_checksum.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_checksum.py b/test/test_checksum.py index f64a64c..d7d7a3f 100644 --- a/test/test_checksum.py +++ b/test/test_checksum.py @@ -1,3 +1,4 @@ +import pytest from src.checksum import modulo11Checksum