From ac6ce9412b6dc5b70c10fb71c9e4aa0b1e77b102 Mon Sep 17 00:00:00 2001 From: Artur Savitskiy Date: Tue, 27 Jun 2023 11:09:35 +0200 Subject: [PATCH] Fix --- последнее ДЗ /find_second_max.py | 41 -------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 последнее ДЗ /find_second_max.py diff --git a/последнее ДЗ /find_second_max.py b/последнее ДЗ /find_second_max.py deleted file mode 100644 index 671c638..0000000 --- a/последнее ДЗ /find_second_max.py +++ /dev/null @@ -1,41 +0,0 @@ -def find_second_max(array): - if array and len(array) > 0: - array.sort() - my_max = array[0] - my_second_max = None - for i in array: - if i > my_max: - my_second_max = my_max - my_max = i - elif i < my_max: - if my_second_max is None: - my_second_max = i - else: - if i > my_max: - my_second_max = i - - return my_second_max - return None - - -################################################# -def verifier(test_name, actual, expected): - print(test_name) - if actual != expected: - print("=======> FAILED! <=======") - print(f"Got value <{actual}>") - print(f"Expected value is <{expected}>") - else: - print("PASSED") - print() - - -second_max_tests = [([1, 6, 3, 6, 54, 3, 6, 3, 1, 2, 8], 8), - ([2, 2, 2, 2, 2, 2, 2, 2, 2], None), - ([2, 2, 2, 2, 2, 2, 2, 2, 4], 2), - ([], None), - ([1, 0, -1], 0), - ([4, -7, 6, 23, -5, 23, -4, 5, 7, 100], 23)] - -for i in range(len(second_max_tests)): - verifier(f"Second max test {i+1}", find_second_max(second_max_tests[i][0]), second_max_tests[i][1])