From 6468241c495f346d6b5409c6ec1ff8c2413bdd37 Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 16:18:37 +0300 Subject: [PATCH 01/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D1=81?= =?UTF-8?q?=D0=B5=D1=82=D0=B2=D0=BE=20=D1=86=D0=B8=D1=84=D1=80,=20=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20X/x=20=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=B0=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B5=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=87=D0=B8=D1=81=D0=BB=D0=B0,=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D0=B0=20=D1=81=20=D0=BD=D0=B5=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D1=8B=D0=BC=20=D0=B2=D1=8B=D1=87?= =?UTF-8?q?=D0=B8=D1=81=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=B2=D0=B7?= =?UTF-8?q?=D0=B2=D0=B5=D1=88=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D1=81=D1=83?= =?UTF-8?q?=D0=BC=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/checksum.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/checksum.py b/src/checksum.py index 74b4fb0..4503ac8 100644 --- a/src/checksum.py +++ b/src/checksum.py @@ -1,14 +1,26 @@ -def modulo11Checksum(ISBNNumber: str): +def modulo11checksum(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] + if len(digits) < 9: + return False + + last_char = isbn_number[-1] + if last_char.upper() == 'X': + check_digit = 10 + elif last_char.isdigit(): + check_digit = digits[-1] + else: + return False total = 0 - for i in range(len(digits) - 1): - weight = 10 + for i in range(9): + weight = 10 - i digit = digits[i] total += digit * weight - checksum = total + checkDigit + checksum = total + check_digit return checksum % 11 == 0 + + + From 036d2248bfbd1737dbd904909e457f47660946d9 Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 16:29:50 +0300 Subject: [PATCH 02/10] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=81=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=B0=D1=8F=20=D1=83=D1=82=D0=B8=D0=BB=D0=B8=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/isbn.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/isbn.py diff --git a/src/isbn.py b/src/isbn.py new file mode 100644 index 0000000..f0c3ab8 --- /dev/null +++ b/src/isbn.py @@ -0,0 +1,13 @@ +from src.checksum import modulo11checksum + +print("Введите номер:") +s = input() +while True: + if modulo11checksum(s): + print("Все верно") + elif s == "-1": + break + else: + print("Что-то не так") + print("Введите номер:") + s = input() \ No newline at end of file From 52916ac22069fe2f0204143137d745015fadd81f Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 16:38:55 +0300 Subject: [PATCH 03/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=83=D1=82=D0=B8=D0=BB=D0=B8=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/checksum.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/checksum.py b/src/checksum.py index 4503ac8..6628803 100644 --- a/src/checksum.py +++ b/src/checksum.py @@ -22,5 +22,17 @@ def modulo11checksum(isbn_number: str): checksum = total + check_digit return checksum % 11 == 0 +print("Введите номер:") +s = input() +while True: + if modulo11checksum(s): + print("Все верно") + elif s == "-1": + break + else: + print("Что-то не так") + print("Введите номер:") + s = input() + From 83d498eaa2516b4fb6a760ebe78d45ce32e6c66b Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 16:40:29 +0300 Subject: [PATCH 04/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=20=D0=BE=D1=81=D1=82=D0=BE=D1=80=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0,=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3?= =?UTF-8?q?=20left=20=3D=3D=20right=20(=D0=B8=D0=BD=D0=B0=D1=87=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=81=D0=BA=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=8F=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin_search.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bin_search.py b/src/bin_search.py index 713abfc..1a5e43b 100644 --- a/src/bin_search.py +++ b/src/bin_search.py @@ -1,10 +1,13 @@ -def binSearch(xs: list[int], x: int): +def bin_search(xs: list[int], x: int): left, right = 0, len(xs) - 1 - while left < right: + for i in range(len(xs) - 1): + if xs[i] > xs[i + 1]: + return -1 + while left <= right: mid = (left + right) // 2 if xs[mid] == x: return mid - if xs[mid] < x: + elif xs[mid] < x: left = mid + 1 else: right = mid - 1 From ede34021d9a4031626e9ea050fd5dd4d9d79b86d Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 16:40:54 +0300 Subject: [PATCH 05/10] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=20=D1=81=20=D1=83=D1=82=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=D1=82=D0=BE=D0=B9,=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D1=8C=20=D0=BE=D0=BD=D0=B0=20=D0=B2=20=D1=81=D0=B0=D0=BC=D0=BE?= =?UTF-8?q?=D0=BC=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B5=20=D1=81=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/isbn.py | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 src/isbn.py diff --git a/src/isbn.py b/src/isbn.py deleted file mode 100644 index f0c3ab8..0000000 --- a/src/isbn.py +++ /dev/null @@ -1,13 +0,0 @@ -from src.checksum import modulo11checksum - -print("Введите номер:") -s = input() -while True: - if modulo11checksum(s): - print("Все верно") - elif s == "-1": - break - else: - print("Что-то не так") - print("Введите номер:") - s = input() \ No newline at end of file From 51b4d7a51bbfc07fdfb7b8e8edeff885bdcfb6e0 Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 16:52:59 +0300 Subject: [PATCH 06/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=82=D0=B5=D1=81=D1=82=D1=8B:=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B1=D0=B8=D0=BD=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=B0:=20=D0=BD=D0=B0=20=D0=BE=D1=82=D1=81=D0=BE=D1=80=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0,=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B8=D0=BD=D0=BD=D1=8B=D0=B9=20=D1=8D=D0=BB?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D1=82;=20=D0=B4=D0=BB=D1=8F=20isbn:=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_bin_searh.py | 11 +++++++---- test/test_checksum.py | 13 ++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/test/test_bin_searh.py b/test/test_bin_searh.py index d18d85b..52b55d5 100644 --- a/test/test_bin_searh.py +++ b/test/test_bin_searh.py @@ -1,13 +1,16 @@ -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], 3) == 2 + +def not_sorted_list(): + assert bin_search([2, 4, 1, 3], 1) == -1 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 diff --git a/test/test_checksum.py b/test/test_checksum.py index f64a64c..e3255e3 100644 --- a/test/test_checksum.py +++ b/test/test_checksum.py @@ -1,9 +1,16 @@ -from src.checksum import modulo11Checksum +from src.checksum import modulo11checksum def test_good(): - assert modulo11Checksum("2-266-11156-8") + assert modulo11checksum("2-266-11156-6") def test_bad(): - assert not modulo11Checksum("2-266-11156-3") + assert not modulo11checksum("2-266-11156-3") + +def test_x(): + assert modulo11checksum("0-8044-2957-X") + +def test_no_correct(): + assert modulo11checksum("123456789Y") + From b0ef15f465b4f94a376f56a2858df757c2bf1d08 Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 16:54:45 +0300 Subject: [PATCH 07/10] =?UTF-8?q?=D0=B2=20readme=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B8=D0=BC=D1=8F=20?= =?UTF-8?q?=D1=84=D0=B0=D0=BC=D0=B8=D0=BB=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .#README.md | 1 + 1 file changed, 1 insertion(+) create mode 120000 .#README.md diff --git a/.#README.md b/.#README.md new file mode 120000 index 0000000..e5c525b --- /dev/null +++ b/.#README.md @@ -0,0 +1 @@ +vboxuser@ubuntu-1.9865 \ No newline at end of file From c2dab4cb6f6624efe7184f7ba864c5ed89939be4 Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 17:14:14 +0300 Subject: [PATCH 08/10] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=82=D0=B0=D0=B1=D1=83=D0=BB=D1=8F?= =?UTF-8?q?=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin_search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin_search.py b/src/bin_search.py index 1a5e43b..5c60ba9 100644 --- a/src/bin_search.py +++ b/src/bin_search.py @@ -1,8 +1,8 @@ def bin_search(xs: list[int], x: int): left, right = 0, len(xs) - 1 for i in range(len(xs) - 1): - if xs[i] > xs[i + 1]: - return -1 + if xs[i] > xs[i + 1]: + return -1 while left <= right: mid = (left + right) // 2 if xs[mid] == x: From 031ca2010f2219c6945ebc205217bf2610e76b75 Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 17:14:57 +0300 Subject: [PATCH 09/10] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=82=D0=B5=D1=81=D1=82=20=D0=BD=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD=D1=83=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_checksum.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_checksum.py b/test/test_checksum.py index e3255e3..a25285a 100644 --- a/test/test_checksum.py +++ b/test/test_checksum.py @@ -12,5 +12,9 @@ def test_x(): assert modulo11checksum("0-8044-2957-X") def test_no_correct(): - assert modulo11checksum("123456789Y") + assert not modulo11checksum("123456789Y") + +def test_len(): + assert not modulo11checksum("31231") + From 6ba9207269af57c8f28ad9aeeaecdbc0c8e4821e Mon Sep 17 00:00:00 2001 From: Egor Starikov Date: Fri, 7 Nov 2025 17:15:54 +0300 Subject: [PATCH 10/10] =?UTF-8?q?=D0=92=20readme=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=84=D0=B0=D0=BC=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D1=8F,=20=D0=B8=D0=BC=D1=8F=20=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=BE=D0=BC=D0=B5=D1=80=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .#README.md | 1 - README.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 120000 .#README.md diff --git a/.#README.md b/.#README.md deleted file mode 120000 index e5c525b..0000000 --- a/.#README.md +++ /dev/null @@ -1 +0,0 @@ -vboxuser@ubuntu-1.9865 \ No newline at end of file diff --git a/README.md b/README.md index e93444f..798a6fa 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +Стариков Егор, группа 142 # Контрольная работа 1 (2 вариант) Темы: Git и GitHub, стандарты оформления кода, хорошие практики, тестирование.