From 022e8e5b94e84fbfb0d573873e649b1123d873b6 Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 15:37:25 +0300 Subject: [PATCH 01/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8,=20=D0=B8?= =?UTF-8?q?=D0=B7-=D0=B7=D0=B0=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B?= =?UTF-8?q?=D1=85=20=D0=BD=D0=B5=20=D0=BF=D1=80=D0=BE=D1=85=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BB=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin_search.py | 2 +- src/checksum.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bin_search.py b/src/bin_search.py index 713abfc..d878d33 100644 --- a/src/bin_search.py +++ b/src/bin_search.py @@ -1,4 +1,4 @@ -def binSearch(xs: list[int], x: int): +def bin_search(xs: list[int], x: int): left, right = 0, len(xs) - 1 while left < right: mid = (left + right) // 2 diff --git a/src/checksum.py b/src/checksum.py index 74b4fb0..3d119b1 100644 --- a/src/checksum.py +++ b/src/checksum.py @@ -1,8 +1,8 @@ -def modulo11Checksum(ISBNNumber: str): +def modulo11_checksum(isbn_number: str): - digits = [int(char) for char in ISBNNumber if char.isdigit()] + digits = [int(char) for char in isbn_number if char.isdigit()] - checkDigit = digits[-1] + check_digit = digits[-1] total = 0 for i in range(len(digits) - 1): @@ -10,5 +10,6 @@ def modulo11Checksum(ISBNNumber: str): digit = digits[i] total += digit * weight - checksum = total + checkDigit + checksum = total + check_digit return checksum % 11 == 0 + From d67c9f59af038090c0fd1f886913eca679c05744 Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 15:41:17 +0300 Subject: [PATCH 02/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B1=D0=B8=D0=BD=20=D0=BF=D0=BE=D0=B8=D1=81?= =?UTF-8?q?=D0=BA?= 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 d878d33..3249226 100644 --- a/src/bin_search.py +++ b/src/bin_search.py @@ -1,6 +1,6 @@ def bin_search(xs: list[int], x: int): left, right = 0, len(xs) - 1 - while left < right: + while left <= right: mid = (left + right) // 2 if xs[mid] == x: return mid From f7a7e46c70c5805861025979ea2f0dbbdbc22cfd Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 15:55:27 +0300 Subject: [PATCH 03/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20ISBN10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/checksum.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/checksum.py b/src/checksum.py index 3d119b1..e26b179 100644 --- a/src/checksum.py +++ b/src/checksum.py @@ -2,14 +2,19 @@ def modulo11_checksum(isbn_number: str): digits = [int(char) for char in isbn_number if char.isdigit()] + if len(digits) != 10: + return False + check_digit = digits[-1] total = 0 + for i in range(len(digits) - 1): - weight = 10 + weight = 10 - i digit = digits[i] total += digit * weight - checksum = total + check_digit + total += check_digit + return checksum % 11 == 0 From 076da68bdf139a8ed03dc716c5bfddf07861e15b Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 15:57:22 +0300 Subject: [PATCH 04/15] =?UTF-8?q?=D0=97=D0=B0=D0=B1=D1=8B=D0=BB=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=BD=D0=B0?= =?UTF-8?q?=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/checksum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checksum.py b/src/checksum.py index e26b179..357873a 100644 --- a/src/checksum.py +++ b/src/checksum.py @@ -16,5 +16,5 @@ def modulo11_checksum(isbn_number: str): total += check_digit - return checksum % 11 == 0 + return total % 11 == 0 From 3fc16b10180fbefabe783b75e61c0429268534d5 Mon Sep 17 00:00:00 2001 From: rmnsmnsk <136500209+rmnsmnsk@users.noreply.github.com> Date: Fri, 7 Nov 2025 16:10:32 +0300 Subject: [PATCH 05/15] Create LICENSE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавляю лицензию --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dd87ca8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 rmnsmnsk + +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 cb85491473f7b45fc6311edb6dfb3f1f82881c98 Mon Sep 17 00:00:00 2001 From: rmnsmnsk <136500209+rmnsmnsk@users.noreply.github.com> Date: Fri, 7 Nov 2025 16:11:54 +0300 Subject: [PATCH 06/15] Create .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавляю gitignore --- .gitignore | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad4a1f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,176 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python +# Edit at https://www.toptal.com/developers/gitignore?templates=python + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +# End of https://www.toptal.com/developers/gitignore/api/python From 205b7033c8b6efca2494188e815260a4f893d1ce Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 16:34:13 +0300 Subject: [PATCH 07/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B5=D1=81=D1=82=D1=8B,=20=D0=B2=20=D1=82.?= =?UTF-8?q?=D1=87=20=D1=82=D0=B5,=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D1=8F=D1=8E=D1=82?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...est_bin_searh.cpython-312-pytest-7.4.4.pyc | Bin 0 -> 6698 bytes ...test_checksum.cpython-312-pytest-7.4.4.pyc | Bin 0 -> 3181 bytes test/test_bin_searh.py | 21 ++++++++++++++---- test/test_checksum.py | 13 ++++++++--- 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 test/__pycache__/test_bin_searh.cpython-312-pytest-7.4.4.pyc create mode 100644 test/__pycache__/test_checksum.cpython-312-pytest-7.4.4.pyc diff --git a/test/__pycache__/test_bin_searh.cpython-312-pytest-7.4.4.pyc b/test/__pycache__/test_bin_searh.cpython-312-pytest-7.4.4.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5848c560d6dd9003caae2582967ad91a6bb06ede GIT binary patch literal 6698 zcmeHLO>Y}T7~a`$J8@DdpymQ5X&_4yJ5JKl6vD>=jyZA4Wwr5a5|>@un%O{I))GSf z54~{WW<}z6AaOyJN~D!g4xD@fC7g2NeP?&=O=}#dlBG&`wEN7=&gag&AJ5FMg+g9} z@bf=~+FwMH{=`fgyB5!Xmn4eYMNF+( zd>m1j(7>A3E@?pbw%dFu$^>T#=tK9Wh@z+-?_Ieo; z0_;@J4@=EfG$q!?uTko`?0x7BH<7yl-%F=z>13SGQ?+ys14&hcG)&BmSc!?bdCuH) zR3=Odn77!p#70JBMFHA9(;)MLIrr>uz)SY2b93` zR0Ebz)G!wuGe*RSVrl__+#a;OTotA*MKZdXg(t~znMuni)FFYk7B;db@J z?HVJyT_bh3X*|H~YM>8FTNSRCeE>6MIfS0*gO9y`eIL7uO;RT-bmp=<1-C5R>AFy$ zj>+D^L5m3QBFqECE-CSFYiyzSDe+mAOFnCZqkbhms~BtG4WWVcMqmR4^=dp|cc2dH za?ca3oT%e{hUp>rL?GYf0BJ7}q5q`4@-=C%B4{t_Y?k(FuNdvsGNkdmPqoIWTE~&V*)ShjSy_ z;aqBe(|CX#R)rllzz)yubOrms0}va|KKi6Z*y|FuC?l*PAUCn{gG{S1rtCIWT0~e! z*g)6>;5cY%NsEasjR`%k)enHs--8Nx_T#?*AfcZ>8RzqxI)ADzoQ(7NU0oPrsb><# zG=iPJK3h^kWJ`i!O|%r`NrabROR1LX6s`5R*-~z&i-e<3l$g*yyi|zK2$%JcRiI!1 zMbTWp8MN3(P>P3&9xoZMLOoOGhe-S6LhcIB@ISkdQ{y8+-`NPk7srGVeAJK=vbJAi zK+3m4@ZW-$tspD`3_iC`dH*^A;AZf@?Q{0PAN%PY9k5V=%62gLGI=wlB1>4~K^ z8=2{yF1rOq(VQLM0+-@rD%{MLnENfO1#qL=`xF_;H-=Ik&2UyNrI)4E!}wYWuSmr$ zkvO6Xf+d`SP!2JbPOKW@WP4$L>^JC<=YGPzgoemxIa0pA6++0VBt4d%NsDJXA>}iZ WkQId0GhHUPF|~jNE9VG8+5QD12-R2s literal 0 HcmV?d00001 diff --git a/test/__pycache__/test_checksum.cpython-312-pytest-7.4.4.pyc b/test/__pycache__/test_checksum.cpython-312-pytest-7.4.4.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8f1c2eddf0228e4cf4994b4b278f4f125cd94183 GIT binary patch literal 3181 zcmeHJPfrs;6rb7M{-IDJViaOxY77aBw6I$!n5a>sS5BTdxLLYOTiid*%vLD2i7~`) zV7&MR2w%YO;Dv*v$y_*i@@BvjC*MpvZG#93@g$SkH*em~ym>qOdw)Ks(=s|rnqTakC5AXq6`sTAU=kdRnE9u)s=GumzwQVy*wZ`Zggw14 zIAa}_Ryf*6brWu-sYGdce&60}}Pc;d@?`@T-)%q+aCMR>-Ng-!LkE(TR zrB?BxN{V}__464 z5(du*2?-muRzu?3k>zewJv*=?cmp;J^3&SJ8~u}fd(z%BPr1dJOyXDJiFFR))AF*r{km+-46++)dAAQCg=I!xFV0fI2_>XuU}RU%4mf|xsc z7YkD@?fiXLn<8VN?PM%`f?#}lBpib1&`|!fc&PqyJXB>Il%tG?5EF4zabmyEF_$+B zuoP|Wq)c&jDmUO z8j$`BFyEg63Y3R!$N-tPJC6u=UMFEtvOG5^MP+ga7I5dM?||^wuD34Gzi9ftw$Qpj z-_sUOi3l&wtc@;l3;$8HbK>@Rm6Rv9K;7|FkpbB;a3uw}R&0k%z)S8l-5g=GwDb2p z%@Bythgeb;SY!~?vvI3kUFF&i2BlGsxa*`6K}ppWu|!8kcooTpC@JP-0p9*9Ufzhj zCY(W7zm3F^!fTF__eJIIJ|xqylGow%HjwWs#&{p0EwqQG4&oT+IJtWeSMcIt5@S=S F_zA?P58eO( literal 0 HcmV?d00001 diff --git a/test/test_bin_searh.py b/test/test_bin_searh.py index d18d85b..060dcd1 100644 --- a/test/test_bin_searh.py +++ b/test/test_bin_searh.py @@ -1,13 +1,26 @@ -from src.bin_search import binSearch +from src.bin_search import bin_search def test_middle(): - assert binSearch([1, 2, 3, 4, 5], 4) == 3 + assert bin_search([1, 2, 3, 4, 5], 4) == 3 def test_start(): - assert binSearch([1, 2, 3, 4], 2) == 1 + assert bin_search([1, 2, 3, 4], 2) == 1 def test_not_in_list(): - assert binSearch([1, 2, 3, 4], 5) == -1 + assert bin_search([1, 2, 3, 4], 5) == -1 + +def test_single(): + assert bin_search([6], 6) == 0 + assert bin_search([2], 3) == -1 + +def empty(): + assert bin_search([], 8) == -1 + +def first(): + assert bin_search([5, 2, 3, 4], 5) == 0 + +def last(): + assert bin_search([1, 2, 3, 8], 8) == 3 \ No newline at end of file diff --git a/test/test_checksum.py b/test/test_checksum.py index f64a64c..e99c958 100644 --- a/test/test_checksum.py +++ b/test/test_checksum.py @@ -1,9 +1,16 @@ -from src.checksum import modulo11Checksum +from src.checksum import modulo11_checksum def test_good(): - assert modulo11Checksum("2-266-11156-8") + assert modulo11_checksum("2-266-11156-6") +def test_only_digits(): + assert modulo11_checksum("2266111566") + +def test_wrong_length(): + assert not modulo11_checksum("12323") + assert not modulo11_checksum("1234123215678901234") def test_bad(): - assert not modulo11Checksum("2-266-11156-3") + assert not modulo11_checksum("2-266-11156-3") + From 0c378cfa4bc46fcee5d95a326b6679416832f08e Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 16:55:57 +0300 Subject: [PATCH 08/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20+=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=BD=D0=B0=20=D1=8D=D1=82?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...est_bin_searh.cpython-312-pytest-7.4.4.pyc | Bin 6698 -> 8119 bytes ...test_checksum.cpython-312-pytest-7.4.4.pyc | Bin 3181 -> 4128 bytes test/test_bin_searh.py | 14 +++++++++----- test/test_checksum.py | 3 +++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/__pycache__/test_bin_searh.cpython-312-pytest-7.4.4.pyc b/test/__pycache__/test_bin_searh.cpython-312-pytest-7.4.4.pyc index 5848c560d6dd9003caae2582967ad91a6bb06ede..33ca47440b881f24cf76ffff93d1d5c8672e5543 100644 GIT binary patch delta 461 zcmZ2wvfZBVG%qg~0}%NC;?2xun#d=?7&TEnlq-d+g&~T+l2Ma;V}rUd8&^qcaY_8< z6~c>{*o(A)%8OVh@8egW+$kmvlUph_or#STtZuTcr1<2$VqzRJEDQ|O8B!P~ujN+W zTp{?Bku{wmg>%v5HQXvd?h8g1F25qq$tl8W!kWxQtRQ3AfJ7-1khs`5xl35KUI=Vp zW?orhW==|cW?n&QNs%K^S_X)VPXLJqhWo6l*J*|7K}KI;RlU!ud!5FpNCW5_O@Uh+ zNu`-NC7F4}MG_1QlT##fnTi}IpOcj0@&L*+g1l`y`IDp`|0gy^MxD=WOpJP9od92- BiERJ? delta 141 zcmdmPzsiK~G%qg~0}!nH!khV?aU!1tW5`7HP?kzYO|Fe?>cWhyn>PzDVv^8gDdGgG zDq;f>>>z>zL~u@y5px2nSt2%_iIHWpqog>KCjaD{a@C3}8HzMOD%60)FAkgB{FKt1 bRJ$TKAeRw{iw!1M$?I`_W@BX30V@OmQ2QVF diff --git a/test/__pycache__/test_checksum.cpython-312-pytest-7.4.4.pyc b/test/__pycache__/test_checksum.cpython-312-pytest-7.4.4.pyc index 8f1c2eddf0228e4cf4994b4b278f4f125cd94183..5cccac2da8bbf7a77ea26ae14840457663fca5f7 100644 GIT binary patch delta 362 zcmaDWu|R?MG%qg~0}wd=4k_gU1gQ-H3psNH8#xsD&HFm>4ZSaWFC( LeFm~r!KMHJdV*l1 delta 98 zcmZ3W@K%ENG%qg~0}$|j;ms_V$ScX{G*R7|rIJyTePf9yHjdg&k u7=gH05lDPsW@Kc%&%n^aaFs#p6B{F=9*EHX#Ky#E@tK2>(WpoQs0sjUY!!I` diff --git a/test/test_bin_searh.py b/test/test_bin_searh.py index 060dcd1..e93048b 100644 --- a/test/test_bin_searh.py +++ b/test/test_bin_searh.py @@ -16,11 +16,15 @@ def test_single(): assert bin_search([6], 6) == 0 assert bin_search([2], 3) == -1 -def empty(): +def test_empty(): assert bin_search([], 8) == -1 -def first(): - assert bin_search([5, 2, 3, 4], 5) == 0 +def test_first(): + assert bin_search([1, 2, 3, 4], 1) == 0 -def last(): - assert bin_search([1, 2, 3, 8], 8) == 3 \ No newline at end of file +def test_last(): + assert bin_search([1, 2, 3, 8], 8) == 3 + +def test_invaild_input(): + assert bin_search(None, 5) == -1 + assert bin_search([1, 2, "с"], 5) == -1 \ No newline at end of file diff --git a/test/test_checksum.py b/test/test_checksum.py index e99c958..6e1de64 100644 --- a/test/test_checksum.py +++ b/test/test_checksum.py @@ -14,3 +14,6 @@ def test_wrong_length(): def test_bad(): assert not modulo11_checksum("2-266-11156-3") +def test_input(): + assert not modulo11_checksum(None) + assert not modulo11_checksum("") From 2d3e95b1974a1ad4814cd7eae69b82cdaa06c4ee Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 16:57:12 +0300 Subject: [PATCH 09/15] =?UTF-8?q?=D0=9D=D0=B5=20=D0=BF=D1=80=D0=BE=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=BB=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_bin_searh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_bin_searh.py b/test/test_bin_searh.py index e93048b..1bce949 100644 --- a/test/test_bin_searh.py +++ b/test/test_bin_searh.py @@ -27,4 +27,4 @@ def test_last(): def test_invaild_input(): assert bin_search(None, 5) == -1 - assert bin_search([1, 2, "с"], 5) == -1 \ No newline at end of file + assert bin_search([1, 2, "с"], 5) == -1 From 9e5d4280ff0708c5f49757839e898682b9245843 Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 17:08:27 +0300 Subject: [PATCH 10/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=83=D1=82=D0=B8=D0=BB=D0=B8=D1=82=D1=83=20+=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__pycache__/bin_search.cpython-312.pyc | Bin 0 -> 777 bytes src/__pycache__/checksum.cpython-312.pyc | Bin 0 -> 867 bytes src/bin_search.py | 11 +++++++++++ src/checksum.py | 22 +++++++++++++++++---- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/__pycache__/bin_search.cpython-312.pyc create mode 100644 src/__pycache__/checksum.cpython-312.pyc diff --git a/src/__pycache__/bin_search.cpython-312.pyc b/src/__pycache__/bin_search.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d1f19f07b1be55007af7e1f91f69d6c96c909112 GIT binary patch literal 777 zcmZWn&ubGw6n?WmqGV0hbdyR&(Le)+l7@;<#NsI;cqm8?f+8i&PMf94MrT)O!UlTq zu!%ivQ0N{a)T8uI@g!7;i-&+-a$Ah29Mm^4X#+l(H{Un&&71EH^C=dK0><({fs!S}I-z7o(uLR3Q=uVdr9jxX0?FO(8VS; z-jZ6PBRbL^cF0yZYNAw^n&_(~JK)H?U5D)5!hOM!i!ir_8WwS6tc04DXvz~jsd`qE z9IiA-R^A-`!5DHILvCQm`^I;R8kS*NcF8Q$K&l#+9f*dBsY=akgmDq$Zx|2*x9N@@ z$jsQSprB^xRs?r$PGY>8uheTa&+4_3nP0Q)oJDInn<7}-x}CRJIlpa~TNW*`a%J^J zBZ!_;wt!{0C+j_?1Nfn&yzSodsdD23>#GS)OFivWxsGHIQ-6XWFS_KLy5y&O#V>05 ztCk97Tni(hCEpeOg||=qm)&P>=AbZ$#=T4@*H<-s+W0_3opZ^_y`TcW>#eU%QA&0ZvG=MjpGES q@x_f=U4K=j_gM<*q_1lTLXi*>3Mmrz?)YN&ZU_jEwO@Rioc;^Y|FTa2 literal 0 HcmV?d00001 diff --git a/src/__pycache__/checksum.cpython-312.pyc b/src/__pycache__/checksum.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..30c03b5080b6f4eaef8d3c65aa7dd45fbc1541e2 GIT binary patch literal 867 zcmZuv&ubG=5T3U`)1<3So5otP7AGjG32QW#L)9!lCa z0r>41fiN9#(1&0H6j0#-qmbv^J+j6mST~~4B|W3B6qi&(#^kODh*&%a=h3?XW;bSm z85D)B4x(g@SdfO7L}qdzGm9etHnGS9U%RYFX7?-pJ}XH4!qrt-73?&l;}alc*b!^Qv6P9H;PR z$;>XhM015zRmhQc+DBrD9f3rl>hi)#A9RB1mN>lGKoseoeYk zy!vR(jTTGF%5o`{$^>5H6jt+Qpzl#tU@tQ06y8n#h+J%*jQtu*{*-1L=}*_bOnsi( zp03Hx*b8k(nyt*E+7rXo>(8D#OW(vHkK8}h=&xU{+-deomAO5s|MjHv Date: Fri, 7 Nov 2025 17:09:28 +0300 Subject: [PATCH 11/15] =?UTF-8?q?=D0=9D=D0=B5=20=D0=BF=D1=80=D0=BE=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=BB=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/checksum.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/checksum.py b/src/checksum.py index 49cc80f..d0aa53f 100644 --- a/src/checksum.py +++ b/src/checksum.py @@ -23,12 +23,12 @@ def modulo11_checksum(isbn_number: str): while True: isbn = input("Введите строку: ") - + if isbn == "-1": print("Выход") break - + if modulo11_checksum(isbn): print("correct") else: - print("incorrect") \ No newline at end of file + print("incorrect") From 9e81ae1723724871ebdf32be18f2a028468fc07b Mon Sep 17 00:00:00 2001 From: rmnsmnsk <136500209+rmnsmnsk@users.noreply.github.com> Date: Fri, 7 Nov 2025 17:12:19 +0300 Subject: [PATCH 12/15] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e93444f..3f64f31 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Темы: Git и GitHub, стандарты оформления кода, хорошие практики, тестирование. +Работу выполнил Семенский Роман Николаевич из группы Б-42. + ## Этапы выполнения работы - Сделать **fork** этого репозитория From a061a70b0bfb8e5baa8784c6f90cbbbdfd2c2a01 Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 17:51:33 +0300 Subject: [PATCH 13/15] =?UTF-8?q?=D0=AF=20=D0=B7=D0=B0=D0=B1=D1=8B=D0=BB?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B2=D0=BE=D1=82=20=D1=8D=D1=82=D0=B8=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=BD=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20(=D1=83?= =?UTF-8?q?=D1=82=D0=B8=D0=BB=D0=B8=D1=82=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=B0=20=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB,=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B8=D0=BB=D0=B8=20=D1=82=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__pycache__/bin_search.cpython-312.pyc | Bin 777 -> 830 bytes src/__pycache__/checksum.cpython-312.pyc | Bin 867 -> 867 bytes src/bin_search.py | 4 ++++ src/checksum.py | 12 ------------ src/utilit.py | 11 +++++++++++ ...est_bin_searh.cpython-312-pytest-7.4.4.pyc | Bin 8119 -> 8920 bytes ...test_checksum.cpython-312-pytest-7.4.4.pyc | Bin 4128 -> 4136 bytes test/test_bin_searh.py | 3 +++ test/test_checksum.py | 2 +- 9 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 src/utilit.py diff --git a/src/__pycache__/bin_search.cpython-312.pyc b/src/__pycache__/bin_search.cpython-312.pyc index d1f19f07b1be55007af7e1f91f69d6c96c909112..d964acb362727816a6990135ebdc2320880ef5ba 100644 GIT binary patch delta 197 zcmeBV+sDRtnwOW00SNNg_%hjYtdr{)CD_@D^NUJSQzlPk%;ORUDg-GmUNf1O$xfJqfrG0jY=TpF)FpQD z8~lO~goG#iGZlJ*l&xea5&=?0LO|jdhfQvNN@-52U6B}&3pPOp$oRm_$jJDCNs^Io Vg2@c#iIyK2fXoHLUqBRCHvre)DdqqG delta 131 zcmdnT*2%_qnwOW00SHun@n+s)oX8i-^p9a;Y8^`oQwjTIR>okvEJP07;_;5C8xG delta 22 ccmaFN_LzA)xRtNxX*A~kF diff --git a/test/__pycache__/test_checksum.cpython-312-pytest-7.4.4.pyc b/test/__pycache__/test_checksum.cpython-312-pytest-7.4.4.pyc index 5cccac2da8bbf7a77ea26ae14840457663fca5f7..93c41a80264f98139d33d76233931e094bca762e 100644 GIT binary patch delta 41 vcmZ3WutI_NG%qg~0}v?u<;}ddk#{{GuTV*9aY=k;URh#hPRizkeDRC`0)!24 delta 33 ncmZ3Xut0(LG%qg~0}wd= Date: Fri, 7 Nov 2025 18:23:06 +0300 Subject: [PATCH 14/15] =?UTF-8?q?=D0=92=20=D1=83=D1=81=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B1=D1=8B=D0=BB=D0=BE=20=D0=BD=D0=B0=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=B0=D0=BD=D0=BE,=20=D1=87=D1=82=D0=BE=20=D0=BE?= =?UTF-8?q?=D0=B1=D1=8F=D0=B7=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B2=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5=20checksum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__pycache__/checksum.cpython-312.pyc | Bin 867 -> 1249 bytes src/checksum.py | 13 +++++++++++++ src/utilit.py | 11 ----------- 3 files changed, 13 insertions(+), 11 deletions(-) delete mode 100644 src/utilit.py diff --git a/src/__pycache__/checksum.cpython-312.pyc b/src/__pycache__/checksum.cpython-312.pyc index d7c658c940f8e98294d9e13136a9caab5498ef36..5763b32c4755519c258493b23ba67b4caccf24c2 100644 GIT binary patch delta 526 zcmaFN_K>swG%qg~0}w3c;=llq4+fumfYfw`6oyoWG^P~B7M3W+RHhWB zYz+p6B1B1zK0k_zb^XrR>Qj<$=ac1Tv=YyGknruZNWkupZ0_3>7#N5>Q z_*<+6MVWaew^%dt3Q9|Ev1Aq}<*j7+3{=BVBnBjYaoFVMrC%vKQIY1N-r?}%mAc5Xfd$xbW~kpmb}Trd4bE@`wENC11`Rs{2~`bbuRPkcCb9) z=AU5FWpk59aDvVi9{C$Qf)BZ6W`tbfRssoWUgeQ_2&A>I@W_1-W#H!jz|O!TRips4 F3jl->o5TPB delta 141 zcmaFJ`Iyb-G%qg~0}y;;0sv$v8mIsO diff --git a/src/checksum.py b/src/checksum.py index bf430d6..6eaf316 100644 --- a/src/checksum.py +++ b/src/checksum.py @@ -19,4 +19,17 @@ def modulo11_checksum(isbn_number: str): total += check_digit return total % 11 == 0 +if __name__ == "__main__": + print("Проверка ISBN-10. Для выхода введите -1") + while True: + isbn = input("Введите ISBN: ") + + if isbn == "-1": + print("Выход") + break + + if modulo11_checksum(isbn): + print("correct") + else: + print("incorrect") diff --git a/src/utilit.py b/src/utilit.py deleted file mode 100644 index 1c14dee..0000000 --- a/src/utilit.py +++ /dev/null @@ -1,11 +0,0 @@ -from checksum import modulo11_checksum - -print("Проверка ISBN-10. Для выхода введите -1") -while True: - isbn = input("Введите ISBN: ") - if isbn == "-1": - break - if modulo11_checksum(isbn): - print("correct") - else: - print("incorrect") \ No newline at end of file From 5081c60fa90a3a6ba7bd3461d0bc76703de46d88 Mon Sep 17 00:00:00 2001 From: RomanSemenskiy Date: Fri, 7 Nov 2025 18:25:10 +0300 Subject: [PATCH 15/15] =?UTF-8?q?=D0=9E=D1=84=D0=BE=D1=80=D0=BC=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_bin_searh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_bin_searh.py b/test/test_bin_searh.py index 75f93df..2b6dacd 100644 --- a/test/test_bin_searh.py +++ b/test/test_bin_searh.py @@ -30,4 +30,4 @@ def test_invaild_input(): assert bin_search([1, 2, "с"], 5) == -1 def test_unsorted_array(): - assert bin_search([3, 1, 2], 2) == -1 \ No newline at end of file + assert bin_search([3, 1, 2], 2) == -1