From bceec2c1009553dd9496f6138efae9e07bd5f8f1 Mon Sep 17 00:00:00 2001 From: MariiaByvalkina Date: Thu, 23 Oct 2025 14:04:45 +0300 Subject: [PATCH 01/11] Add file with LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..13f6c42 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 MariiaByvalkina + +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 e919803bca43b0ca930eef6c13377d9dec8c85d2 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 14:09:01 +0300 Subject: [PATCH 02/11] Add file with 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 1679e30df5cc54351eaf2304162985c4b5b68afd Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 14:28:02 +0300 Subject: [PATCH 03/11] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=20snake=5Fcase,=20=D1=87=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=BB=20ruff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fast_pow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fast_pow.py b/src/fast_pow.py index 1ba1dc1..755e207 100644 --- a/src/fast_pow.py +++ b/src/fast_pow.py @@ -1,4 +1,4 @@ -def fastPow(number, power): +def fast_pow(number, power): result = number while power != 1: result *= result From 4324abc17283622ea00dd54080f7eb6c3dde6826 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 14:29:06 +0300 Subject: [PATCH 04/11] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=20snake=5Fcase=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=80=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luhn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/luhn.py b/src/luhn.py index 11d993c..da0f897 100644 --- a/src/luhn.py +++ b/src/luhn.py @@ -1,5 +1,5 @@ -def luhnСheck(cardNumber): - digits = [int(d) for d in str(cardNumber) if d.isdigit()] +def luhn_check(card_number): + digits = [int(d) for d in str(card_number) if d.isdigit()] control = digits.pop() parity = (len(digits))%2 total = 0 From 2cfd30fc76073503477d6fdbc4db49652d743a40 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 14:31:47 +0300 Subject: [PATCH 05/11] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=20=D1=81=D0=BE=D0=B3?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D0=BD=D0=BE=20PEP8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luhn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luhn.py b/src/luhn.py index da0f897..c5e85ca 100644 --- a/src/luhn.py +++ b/src/luhn.py @@ -1,7 +1,7 @@ def luhn_check(card_number): digits = [int(d) for d in str(card_number) if d.isdigit()] control = digits.pop() - parity = (len(digits))%2 + parity = (len(digits)) % 2 total = 0 for i in range(len(digits)): if i % 2 == parity: From 791d4ed9059d548e47e151e0920977eefebe8906 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 14:36:35 +0300 Subject: [PATCH 06/11] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=BF=D1=83=D1=81=D1=82=D1=83=D1=8E=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BA=D1=83=20=D0=B2=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=86=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_luhn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_luhn.py b/test/test_luhn.py index 1c021a2..9b8b3b1 100644 --- a/test/test_luhn.py +++ b/test/test_luhn.py @@ -6,4 +6,4 @@ def test_good(): def test_bad(): - assert not luhnСheck("4561 2612 1234 5463") \ No newline at end of file + assert not luhnСheck("4561 2612 1234 5463") From ace5e208bfd532e0c23ecf893c9f8b4e2682ae9b Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 14:41:28 +0300 Subject: [PATCH 07/11] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B2=20?= =?UTF-8?q?=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D0=B8=D0=B8=20=D1=81=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BD=D1=8B=D0=BC=D0=B8=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_fast_pow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_fast_pow.py b/test/test_fast_pow.py index 5e4aebd..aa91d54 100644 --- a/test/test_fast_pow.py +++ b/test/test_fast_pow.py @@ -1,9 +1,9 @@ -from src.fast_pow import fastPow +from src.fast_pow import fast_pow def test_two_power_two(): - assert fastPow(2, 2) == 4 + assert fast_pow(2, 2) == 4 def test_negative(): - assert fastPow(-1, 4) == 1 + assert fast_pow(-1, 4) == 1 From e5cbf217fb5c4b7a04dfa436486bd33a9cafcac4 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 14:42:22 +0300 Subject: [PATCH 08/11] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B0=D0=BB=D0=B3=D0=BE=D1=80=D0=B8=D1=82=D0=BC?= =?UTF-8?q?=D0=B0=20=D0=9B=D1=83=D0=BD=D0=B0=20=D0=B2=20=D1=81=D0=BE=D0=BE?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20=D1=81?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_luhn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_luhn.py b/test/test_luhn.py index 9b8b3b1..d042e3d 100644 --- a/test/test_luhn.py +++ b/test/test_luhn.py @@ -1,9 +1,9 @@ -from src.luhn import luhnСheck +from src.luhn import luhn_check def test_good(): - assert luhnСheck("8571 2612 1234 5467") + assert luhn_check("8571 2612 1234 5467") def test_bad(): - assert not luhnСheck("4561 2612 1234 5463") + assert not luhn_check("4561 2612 1234 5463") From 89c5747ea01ba9929eddf78f3fa56118a369bfb7 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 15:07:25 +0300 Subject: [PATCH 09/11] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=20=D1=81=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fast_pow.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/fast_pow.py b/src/fast_pow.py index 755e207..3346add 100644 --- a/src/fast_pow.py +++ b/src/fast_pow.py @@ -1,5 +1,12 @@ def fast_pow(number, power): - result = number + +result = number + if power < 0: + raise InvalidPowerError("Отрицательная степень не поддерживается") + if not isinstance(power, int): + raise TypeError("Степень всегда является целым числом") + if not isinstance(number, int): + raise TypeError("Число, возводимое в степень должно быть целым") while power != 1: result *= result power = power // 2 From 338eeff6656aabae4a810098fee9e3dbaf6d0bc6 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 15:14:39 +0300 Subject: [PATCH 10/11] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B9=20=D1=84=D0=B0=D0=B9=D0=BB=20fast=5Fpo?= =?UTF-8?q?w,=20=D0=B3=D0=B4=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20?= =?UTF-8?q?=D1=81=20=D0=BE=D1=82=D1=81=D1=82=D1=83=D0=BF=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fast_pow.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fast_pow.py b/src/fast_pow.py index 3346add..da7f07b 100644 --- a/src/fast_pow.py +++ b/src/fast_pow.py @@ -1,12 +1,16 @@ def fast_pow(number, power): -result = number + result = number + if power < 0: raise InvalidPowerError("Отрицательная степень не поддерживается") + if not isinstance(power, int): raise TypeError("Степень всегда является целым числом") + if not isinstance(number, int): raise TypeError("Число, возводимое в степень должно быть целым") + while power != 1: result *= result power = power // 2 From 5098e75b675d7404b82f473c88551f6f1cb570c2 Mon Sep 17 00:00:00 2001 From: Maria Byvalkina Date: Thu, 23 Oct 2025 15:18:42 +0300 Subject: [PATCH 11/11] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20fast=5Fpow=20=D0=B4=D0=BB=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=D0=B9=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20ruff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fast_pow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fast_pow.py b/src/fast_pow.py index da7f07b..9da7776 100644 --- a/src/fast_pow.py +++ b/src/fast_pow.py @@ -3,7 +3,7 @@ def fast_pow(number, power): result = number if power < 0: - raise InvalidPowerError("Отрицательная степень не поддерживается") + raise TypeError("Отрицательная степень не поддерживается") if not isinstance(power, int): raise TypeError("Степень всегда является целым числом")