Skip to content

Comments

Решение контрольной работы. Семенский Роман Николаевич Б-42#13

Open
rmnsmnsk wants to merge 16 commits intopython-course-matmex:mainfrom
rmnsmnsk:main
Open

Решение контрольной работы. Семенский Роман Николаевич Б-42#13
rmnsmnsk wants to merge 16 commits intopython-course-matmex:mainfrom
rmnsmnsk:main

Conversation

@rmnsmnsk
Copy link

@rmnsmnsk rmnsmnsk commented Nov 7, 2025

Задачи:
bin_search:
Было неверно написано, что while left < right - не находил элементы на границах массива (первый и последний)
Исправил на while left <= right - теперь находит все элементы включая граничные

checksum:
Не изменялся вес цифры

В качестве исключений были добавлены:

  1. В обеих задачах проверяется корректность типов данных
  2. В бин поиске дополнительно проверяется отсортированность массива
  3. В задаче на isbn также проверяется длина входящей строки

Остальное:

Также были был добавлены .gitignore и LICENSE, дополнен readme

@rmnsmnsk rmnsmnsk changed the title Решение контрольной задачи Решение контрольной работы Nov 7, 2025
@rmnsmnsk rmnsmnsk changed the title Решение контрольной работы Решение контрольной работы. Семенский Роман Николаевич Б-42 Nov 7, 2025
Copy link

@Godrik0 Godrik0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISBN10: 7/10
Бинарный поиск: 2/5
Оформление: 7/10 (__pycahe__ в PR)

Comment on lines +9 to +14
for i in xs:
if not isinstance(i, int):
return -1

if xs != sorted(xs):
return -1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти проверки полностью лишают смысла весь алгоритм. Поиск в xs имеет сложность $O(N)$, сортировка имеет сложность $O(N \log{N})$.

Comment on lines +6 to +9
digits = [int(char) for char in isbn_number if char.isdigit()]

if len(digits) != 10:
return False
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У Вас пропущена обработка символа X, который может служить контрольной цифрой.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants