-
Notifications
You must be signed in to change notification settings - Fork 173
Чет не хочет... #1276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Чет не хочет... #1276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,9 +26,9 @@ def check_1(lst_obj): | |
| Алгоритм 3: | ||
| Создать множество из списка | ||
|
|
||
| Сложность: !!!. | ||
| Сложность: O(n) | ||
| """ | ||
| lst_to_set = set(lst_obj) # !!! | ||
| lst_to_set = set(lst_obj) # O(n) | ||
| return lst_to_set | ||
|
|
||
|
|
||
|
|
@@ -41,12 +41,12 @@ def check_2(lst_obj): | |
| что такой элемент отстутствует | ||
| в оставшихся справа элементах | ||
|
|
||
| Сложность: !!!. | ||
| Сложность: O(N^2) | ||
| """ | ||
| for j in range(len(lst_obj)): # !!! | ||
| if lst_obj[j] in lst_obj[j+1:]: # !!! | ||
| return False # !!! | ||
| return True # !!! | ||
| for j in range(len(lst_obj)): # O(N) | ||
| if lst_obj[j] in lst_obj[j+1:]: # O(N) | ||
| return False # O(1) | ||
| return True # O(1) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
|
|
||
|
|
||
| ############################################################################################# | ||
|
|
@@ -57,14 +57,14 @@ def check_3(lst_obj): | |
| Вначале выполним для списка сортировку, далее, сравниваем элементы попарно | ||
| Если присутствуют дубли, они будут находиться рядом. | ||
|
|
||
| Сложность: !!! | ||
| Сложность: O(N Log N) | ||
| """ | ||
| lst_copy = list(lst_obj) # !!! | ||
| lst_copy.sort() # !!! | ||
| for i in range(len(lst_obj) - 1): # !!! | ||
| if lst_copy[i] == lst_copy[i+1]: # !!! | ||
| return False # !!! | ||
| return True # !!! | ||
| lst_copy = list(lst_obj) # O(N) | ||
| lst_copy.sort() # O(N Log N) | ||
| for i in range(len(lst_obj) - 1): # O(N) | ||
| if lst_copy[i] == lst_copy[i+1]: # O(1) | ||
| return False # O(1) | ||
| return True # O(1) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
|
|
||
| ############################################################################################# | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,3 +17,28 @@ | |
| Алгоритмизатор должен развивать мышление, а это прежде всего практика. | ||
| А без столкновения со сложностями его не развить. | ||
| """ | ||
| from random import randint | ||
|
|
||
|
|
||
| def check_min2(obj): | ||
| for i in obj: | ||
| minn = True | ||
| for j in obj: | ||
| if i > j: | ||
| minn = False | ||
| if minn: | ||
| return i | ||
|
|
||
|
|
||
| def check_min(obj): | ||
| minn = obj[0] | ||
| for i in obj: | ||
| if i < minn: | ||
| minn = i | ||
| return minn | ||
|
|
||
| lst = [randint(0, 1000) for i in range(40)] | ||
| print(lst) | ||
| print(check_min2(lst)) | ||
| print(check_min(lst)) | ||
| print(sorted(lst)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено как в примере |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,44 @@ | |
| Реализуйте поиск трех компаний с наибольшей годовой прибылью. | ||
| Выведите результат. | ||
| """ | ||
| compamy = { | ||
| 'gazprom': 2000, | ||
| 'navafarm': 300, | ||
| 'microsoft': 3000, | ||
| 'rosnano': 800, | ||
| 'apple': 1500, | ||
| 'adidas': 50 | ||
| } | ||
|
|
||
|
|
||
| def sorted_n2(lst): | ||
| for i in range(len(lst)): | ||
| low_index = i | ||
| for j in range(i + 1, len(lst)): | ||
| if lst[j][1] > lst[low_index][1]: | ||
| low_index = j | ||
| lst[i], lst[low_index] = lst[low_index], lst[i] | ||
| return lst[0:3] | ||
|
|
||
|
|
||
| lst_dict = list(compamy.items()) | ||
| for i in sorted_n2(lst_dict): | ||
| print(f'{i[0]} : {i[1]}') | ||
|
|
||
| print('=' * 20) | ||
|
|
||
|
|
||
| def sorted_n(lst): | ||
| max_value = {} | ||
| lstdict = dict(lst) | ||
| for i in range(3): | ||
| maximum = max(lstdict.items(), key=lambda key_val: key_val[1]) | ||
| del lstdict[maximum[0]] | ||
| max_value[maximum[0]] = maximum[1] | ||
| return max_value | ||
|
|
||
|
|
||
| print(sorted_n(compamy)) | ||
|
|
||
| '''лучшим вариантом будет функция sortetd_n так как имеет | ||
| минимальную вычислительную сложность''' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. где какая сложность? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,3 +27,16 @@ | |
| Для реализации хранилища можно применить любой подход, | ||
| который вы придумаете, например, реализовать словарь. | ||
| """ | ||
| # сложность O(1) | ||
| def autorizacion(users, user_name, user_pass): | ||
| '''реализация проверки допуска к ресурсу''' | ||
| if users.get(user_name): | ||
| if users[user_name]['passowrd'] == user_pass and user_name['active']: | ||
| return 'Доступ разрешен' | ||
| elif users[user_name]['passowrd'] == user_pass and not user_name['active']: | ||
| return 'Необходимо войти в учетную запись' | ||
| elif users[user_name]['password'] != user_pass: | ||
| return 'Вы ввели не верный пароль' | ||
| else: | ||
| return "Пользователя не сущестует" | ||
| '''самая быстрая проверка которая пришла на ум. Быстрая потому что нет цикла''' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. нет второй реализации |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,5 @@ | |
|
|
||
| После реализации структуры, проверьте ее работу на различных сценариях | ||
| """ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,50 @@ | |
|
|
||
| После реализации структуры, проверьте ее работу на различных сценариях | ||
| """ | ||
| class Queueing: | ||
| def __init__(self): | ||
| self.elements = [] | ||
|
|
||
| def is_null(self): | ||
| return self.elements == [] | ||
|
|
||
| def to_queue(self, tasks): | ||
| self.elements.insert(0, tasks) | ||
|
|
||
| def from_queue(self): | ||
| return self.elements.pop() | ||
|
|
||
| def sized(self): | ||
| return len(self.elements) | ||
|
|
||
|
|
||
| class Board_task: | ||
| def __init__(self): | ||
| self.base_queue = Queueing() | ||
| self.queue_for_revision = Queueing() | ||
| self.list_of_completed = [] | ||
|
|
||
| def perform_task(self): | ||
| task = self.base_queue.from_queue() | ||
| self.list_of_completed.append(task) | ||
|
|
||
|
|
||
| def for_revision_task(self): | ||
| task = self.queue_for_revision.from_queue() | ||
| self.queue_for_revision.to_queue(task) | ||
|
|
||
| def add_to_current(self, tasks): | ||
| self.base_queue.to_queue(tasks) | ||
|
|
||
| def from_revision(self): | ||
| task = self.queue_for_revision.from_queue() | ||
| self.base_queue.to_queue(task) | ||
|
|
||
| if __name__ == '__main__': | ||
| taskBoard = Board_task() | ||
| taskBoard.add_to_current("Здача1") | ||
| taskBoard.add_to_current("Здача2") | ||
| taskBoard.add_to_current("Здача3") | ||
| taskBoard.add_to_current("Здача4") | ||
| print(taskBoard.base_queue.elements) | ||
| print(taskBoard.from_revision()) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено как в примере |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не указана сложность