From 0e32e882533d0795f53f2c0cac67ac85324950e2 Mon Sep 17 00:00:00 2001 From: ermmmaks Date: Thu, 23 Oct 2025 13:53:42 +0300 Subject: [PATCH 1/6] Add MIT LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5798c01 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Ermoshkin Maksim + +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. \ No newline at end of file From e450507ad64deca31ef9e3e7dd70636493fbf126 Mon Sep 17 00:00:00 2001 From: ermmmaks Date: Thu, 23 Oct 2025 13:55:13 +0300 Subject: [PATCH 2/6] Add .gitignore --- src/.gitignore | 176 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 src/.gitignore diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..90f8fbb --- /dev/null +++ b/src/.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 \ No newline at end of file From 66c0afa3776ba2c7c89dd748e24b21b08c012fe3 Mon Sep 17 00:00:00 2001 From: ermmmaks Date: Thu, 23 Oct 2025 14:10:19 +0300 Subject: [PATCH 3/6] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=81=D1=82=D0=B0=D0=BC=D0=B8=203=20=D0=B8=204?= =?UTF-8?q?=20=D1=81=D1=82=D1=80=D0=BE=D1=87=D0=BA=D0=B8,=20=D1=82.=D0=BA.?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=B7=D0=B0=20=D1=82=D1=80=D0=B5=D1=82=D1=8C?= =?UTF-8?q?=D0=B5=D0=B9=20=D1=81=D1=82=D1=80=D0=BE=D1=87=D0=BA=D0=B8=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=204=20?= =?UTF-8?q?=D0=B1=D1=8B=20=D0=BD=D0=B5=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=82=D0=B2=D0=BE=D0=B2=D0=B0=D0=BB=20=D0=B0?= =?UTF-8?q?=D0=BB=D0=B3=D0=BE=D1=80=D0=B8=D1=82=D0=BC=D1=83=20=D0=9B=D1=83?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D1=80=D0=BE=D0=B1=D0=B5=D0=BB=D1=8B=20=D0=B2?= =?UTF-8?q?=D0=BE=D0=B7=D0=BB=D0=B5=20%=20=D0=B2=20=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D0=B9=203=20=D1=81=D1=82=D1=80=D0=BE=D1=87=D0=BA=D0=B5?= 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 11d993c..ca1ab58 100644 --- a/src/luhn.py +++ b/src/luhn.py @@ -1,7 +1,7 @@ def luhnСheck(cardNumber): digits = [int(d) for d in str(cardNumber) if d.isdigit()] + parity = (len(digits)) % 2 control = digits.pop() - parity = (len(digits))%2 total = 0 for i in range(len(digits)): if i % 2 == parity: From 79a0782c27ade410163f828d4dbcc20b1c3d4136 Mon Sep 17 00:00:00 2001 From: ermmmaks Date: Thu, 23 Oct 2025 14:41:28 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=B0=D0=BB=D0=B3=D0=BE=D1=80=D0=B8=D1=82=D0=BC?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=81=D1=82=D0=B5=D0=BF=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=BD=D0=B5=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA?= =?UTF-8?q?=D0=BE=20=D1=81=D1=82=D0=B5=D0=BF=D0=B5=D0=BD=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fast_pow.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/fast_pow.py b/src/fast_pow.py index 1ba1dc1..16da2f3 100644 --- a/src/fast_pow.py +++ b/src/fast_pow.py @@ -1,6 +1,10 @@ def fastPow(number, power): result = number - while power != 1: + deg = 1 + while deg * 2 < power: result *= result - power = power // 2 - return result + deg *= 2 + while deg < power: + result *= number + deg += 1 + return result \ No newline at end of file From fd29625174713d28ee507ab39d0808a78ed279a8 Mon Sep 17 00:00:00 2001 From: ermmmaks Date: Thu, 23 Oct 2025 15:05:39 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BE=D1=82=D0=BA=D0=B0=D0=B7=20=D0=BE=D1=82=20=D0=BE=D1=82?= =?UTF-8?q?=D1=80=D0=B8=D1=86=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=81=D1=82=D0=B5=D0=BF=D0=B5=D0=BD=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fast_pow.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/fast_pow.py b/src/fast_pow.py index 16da2f3..546b4a8 100644 --- a/src/fast_pow.py +++ b/src/fast_pow.py @@ -1,10 +1,12 @@ def fastPow(number, power): - result = number - deg = 1 - while deg * 2 < power: - result *= result - deg *= 2 - while deg < power: - result *= number - deg += 1 - return result \ No newline at end of file + if power > 0: + result = number + deg = 1 + while deg * 2 < power: + result *= result + deg *= 2 + while deg < power: + result *= number + deg += 1 + return result + return "Отрицательная степень!" \ No newline at end of file From 548369c0c9c391d4171dd72c4bbabaeb759bfe1f Mon Sep 17 00:00:00 2001 From: ermmmaks Date: Thu, 23 Oct 2025 15:14:57 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BA=D0=B0=D0=BA=D1=83=D1=8E=20=D1=81=D0=BC=D0=BE=D0=B3=20?= =?UTF-8?q?=D1=83=D1=82=D0=B8=D0=BB=D0=B8=D1=82=D1=83=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=BB=D1=83=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luhn.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/luhn.py b/src/luhn.py index ca1ab58..4d392f2 100644 --- a/src/luhn.py +++ b/src/luhn.py @@ -12,3 +12,19 @@ def luhnСheck(cardNumber): else: total += digits[i] return (total + control) % 10 == 0 + +user_number = [] +user_str = str(input("Введите строчку с номером, оканчивающуюся на '-1': ")) + +def check(str): + for i in range(len(str) - 1): + if str[i]+str[i+1] != '-1': + if str[i] in '0123456789': + user_number.append(int(str[i])) + else: + print("Найден неверный символ: ", str[i]) + if luhnСheck(user_number): + return "Номер корректен" + else: + return "Некорректный номер" +print(check(user_str)) \ No newline at end of file