From 462690ae097426da2885058fe98c6a0cabe83f71 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 15:19:31 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/06_unique_combination/main.py | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Module16/06_unique_combination/main.py b/Module16/06_unique_combination/main.py index f0e81d0..c93923e 100644 --- a/Module16/06_unique_combination/main.py +++ b/Module16/06_unique_combination/main.py @@ -1,22 +1,22 @@ # TODO здесь писать код +def merge_sorted_lists(collection1, collection2): + result_collection = [] + for value2 in collection2: + for value1 in collection1: + if value2 == value1: + break + else: + result_collection.append(value2) + print(result_collection) + result_collection.extend(collection1) + print(result_collection) + result_collection.sort() + print(result_collection) + return result_collection # Пример использования: list1 = [1, 3, 5, 7, 9, 5] list2 = [2, 4, 5, 6, 8, 10] - -list1.extend(list2) -list3 = [] -for i_number in range(len(list1)): - for i_next_number in range(i_number + 1, len(list1)+1): - _min = list1[i_number] # можно обойтись без этих переменных, но код станет не очень читаемым... - _max = list1[i_next_number] - if _min > _max: - list1[i_number] = _max - elif _min < _min: - list1[i_number] = _min - else: - list1.remove(_min) - -# merged = merge_sorted_lists(list1, list2) -# print(merged) \ No newline at end of file +merged = merge_sorted_lists(list1, list2) +print(merged) \ No newline at end of file