From fe2a5fddf2ba5bdd9754a3649dec395dbe86ad5a Mon Sep 17 00:00:00 2001 From: korolinakila Date: Mon, 29 Sep 2025 12:48:19 +0300 Subject: [PATCH 01/17] Solution --- solutions/lesson02/task1.py | 8 ++++---- solutions/lesson02/task2.py | 5 +++-- solutions/lesson02/task3.py | 10 ++++++++-- solutions/lesson02/task4.py | 10 ++++++++-- solutions/lesson02/task5.py | 10 ++++++++-- solutions/lesson02/task6.py | 16 +++++++++++++--- solutions/lesson02/task7.py | 9 +++++++-- 7 files changed, 51 insertions(+), 17 deletions(-) diff --git a/solutions/lesson02/task1.py b/solutions/lesson02/task1.py index c782dcd88..188725c2d 100644 --- a/solutions/lesson02/task1.py +++ b/solutions/lesson02/task1.py @@ -1,4 +1,4 @@ -def get_factorial(num: int) -> int: - factorial = 1 - # ваш код - return factorial +import sys + +# Print the full path of the Python interpreter +print(sys.executable) \ No newline at end of file diff --git a/solutions/lesson02/task2.py b/solutions/lesson02/task2.py index b91420c56..4b62c789c 100644 --- a/solutions/lesson02/task2.py +++ b/solutions/lesson02/task2.py @@ -1,4 +1,5 @@ def get_doubled_factorial(num: int) -> int: factorial = 1 - # ваш код - return factorial + for i in range(num, 1, -2): + factorial = factorial*i + return factorial \ No newline at end of file diff --git a/solutions/lesson02/task3.py b/solutions/lesson02/task3.py index ee2a84ecf..bb9b907bc 100644 --- a/solutions/lesson02/task3.py +++ b/solutions/lesson02/task3.py @@ -1,4 +1,10 @@ def get_amount_of_ways_to_climb(stair_amount: int) -> int: step_prev, step_curr = 1, 1 - # ваш код - return step_curr + + for i in range(1, stair_amount): + fixing = step_curr + step_curr = step_curr+step_prev + step_prev = fixing + + + return step_curr \ No newline at end of file diff --git a/solutions/lesson02/task4.py b/solutions/lesson02/task4.py index 45ff4bb42..7c91fe1e9 100644 --- a/solutions/lesson02/task4.py +++ b/solutions/lesson02/task4.py @@ -1,4 +1,10 @@ def get_multiplications_amount(num: int) -> int: multiplications_amount = 0 - # ваш код - return multiplications_amount + + while num//2!=0: + if num%2 == 1: + multiplications_amount+=1 + num -= 1 + num = num//2 + multiplications_amount+=1 + return multiplications_amount \ No newline at end of file diff --git a/solutions/lesson02/task5.py b/solutions/lesson02/task5.py index 8fb9a048d..dc8989177 100644 --- a/solutions/lesson02/task5.py +++ b/solutions/lesson02/task5.py @@ -1,3 +1,9 @@ def get_gcd(num1: int, num2: int) -> int: - # ваш код - return num1 + while num1 != 0 and num2 != 0: + if num1 > num2: + num1 = num1 % num2 + else: + num2 = num2 % num1 + + + return(num1+num2) diff --git a/solutions/lesson02/task6.py b/solutions/lesson02/task6.py index bec4b6cd9..5ac277de0 100644 --- a/solutions/lesson02/task6.py +++ b/solutions/lesson02/task6.py @@ -1,4 +1,14 @@ def get_sum_of_prime_divisors(num: int) -> int: - sum_of_divisors = 0 - # ваш код - return sum_of_divisors + sum_of_divisors = 0 + divisor = 2 + while divisor <= num: + simple = True + if num % divisor == 0: + + for i in range(2, divisor): + if divisor%i == 0: + simple = False + if simple: + sum_of_divisors += divisor + divisor += 1 + return sum_of_divisors \ No newline at end of file diff --git a/solutions/lesson02/task7.py b/solutions/lesson02/task7.py index 4b2d73beb..9fc3cf393 100644 --- a/solutions/lesson02/task7.py +++ b/solutions/lesson02/task7.py @@ -1,5 +1,10 @@ def is_palindrome(num: int) -> bool: num_reversed = 0 num_origin = num - # ваш код - return num_origin == num_reversed + + while num > 0: + digit = num % 10 + num_reversed = num_reversed * 10 + digit + num = num // 10 + + return num_origin == num_reversed \ No newline at end of file From 1b1fb87b18696a0a99ad209018bb514842d770c2 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Thu, 9 Oct 2025 22:59:44 +0300 Subject: [PATCH 02/17] Matvey Makar --- solutions/lesson03/task1.py | 6 ++++-- solutions/lesson03/task2.py | 16 ++++++++++++++-- solutions/lesson03/task3.py | 4 ++-- tempCodeRunnerFile.python | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 tempCodeRunnerFile.python diff --git a/solutions/lesson03/task1.py b/solutions/lesson03/task1.py index f1d8fe26b..a9246aa16 100644 --- a/solutions/lesson03/task1.py +++ b/solutions/lesson03/task1.py @@ -1,3 +1,5 @@ def flip_bits_in_range(num: int, left_bit: int, right_bit: int) -> int: - # ваш код - return num \ No newline at end of file + maska = ((1 << right_bit) - 1) ^ ((1 << (left_bit - 1)) - 1) + + return num^maska + diff --git a/solutions/lesson03/task2.py b/solutions/lesson03/task2.py index a3a738c2a..199b0c119 100644 --- a/solutions/lesson03/task2.py +++ b/solutions/lesson03/task2.py @@ -1,3 +1,15 @@ def get_cube_root(n: float, eps: float) -> float: - # ваш код - return n \ No newline at end of file + sign = 1 + if n < 0: + n = abs(n) + sign = -1 + + root = n / 2 + + while abs(root**3 - n) >= eps: + if root**3 > n: + root = root / 2 + elif root**3 < n: + root = root * 1.5 + + return root * sign diff --git a/solutions/lesson03/task3.py b/solutions/lesson03/task3.py index 5e91a6ac5..08007e978 100644 --- a/solutions/lesson03/task3.py +++ b/solutions/lesson03/task3.py @@ -1,3 +1,3 @@ def get_nth_digit(num: int) -> int: - # ваш код - return 0 + + return int(str((num-1)*2)[0]) \ No newline at end of file diff --git a/tempCodeRunnerFile.python b/tempCodeRunnerFile.python new file mode 100644 index 000000000..51cf89807 --- /dev/null +++ b/tempCodeRunnerFile.python @@ -0,0 +1 @@ +print("asd") \ No newline at end of file From 78911a9667a26ada84b35d85068bc4b01ae5d751 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Fri, 10 Oct 2025 14:47:30 +0300 Subject: [PATCH 03/17] Makarov Matvey --- solutions/lesson03/task1.py | 2 +- solutions/lesson03/task2.py | 2 +- solutions/lesson03/task3.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/solutions/lesson03/task1.py b/solutions/lesson03/task1.py index a9246aa16..91b26cb60 100644 --- a/solutions/lesson03/task1.py +++ b/solutions/lesson03/task1.py @@ -1,5 +1,5 @@ def flip_bits_in_range(num: int, left_bit: int, right_bit: int) -> int: maska = ((1 << right_bit) - 1) ^ ((1 << (left_bit - 1)) - 1) - return num^maska + return num^maska #Макаров Матвей 514 diff --git a/solutions/lesson03/task2.py b/solutions/lesson03/task2.py index 199b0c119..ba4dd56ad 100644 --- a/solutions/lesson03/task2.py +++ b/solutions/lesson03/task2.py @@ -12,4 +12,4 @@ def get_cube_root(n: float, eps: float) -> float: elif root**3 < n: root = root * 1.5 - return root * sign + return root * sign #Макаров Матвей 514 diff --git a/solutions/lesson03/task3.py b/solutions/lesson03/task3.py index 08007e978..c46baafc1 100644 --- a/solutions/lesson03/task3.py +++ b/solutions/lesson03/task3.py @@ -1,3 +1,3 @@ def get_nth_digit(num: int) -> int: - - return int(str((num-1)*2)[0]) \ No newline at end of file + + return int(str((num-1)*2)[0]) #Макаров Матвей 514 \ No newline at end of file From e28a0cdc518acff5a5782ca07b862fb05c179458 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Fri, 17 Oct 2025 22:21:30 +0300 Subject: [PATCH 04/17] Makarov Matvey 514 --- .vscode/settings.json | 7 +++++++ solutions/lesson04/task1.py | 10 ++++++++-- solutions/lesson04/task2.py | 15 +++++++++++++-- solutions/lesson04/task3.py | 9 ++++++--- solutions/lesson04/task4.py | 12 ++++++++++-- solutions/lesson04/task5.py | 17 +++++++++++++++-- solutions/lesson04/task6.py | 14 ++++++++++++-- 7 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..9b388533a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/solutions/lesson04/task1.py b/solutions/lesson04/task1.py index 47384423a..0a3bd0d10 100644 --- a/solutions/lesson04/task1.py +++ b/solutions/lesson04/task1.py @@ -1,3 +1,9 @@ def is_arithmetic_progression(lst: list[list[int]]) -> bool: - # ваш код - return False \ No newline at end of file + lst = sorted(lst) + ok = True + for i in range(len(lst)-2): + if lst[i] - lst[i+1] != lst[i+1] - lst[i+2]: + ok = False + break + + return ok diff --git a/solutions/lesson04/task2.py b/solutions/lesson04/task2.py index 4591d0a3e..f918a8f9c 100644 --- a/solutions/lesson04/task2.py +++ b/solutions/lesson04/task2.py @@ -1,3 +1,14 @@ def merge_intervals(intervals: list[list[int, int]]) -> list[list[int, int]]: - # ваш код - return [[0,0]] \ No newline at end of file + intervals = sorted(intervals) + intervals.append([-2, -1]) + res = [] + for i in range(len(intervals)-1): + if intervals[i][1]>=intervals[i+1][0] and intervals[i][1]=intervals[i+1][1]: + intervals[i+1] = intervals[i] + + else: + res.append(intervals[i]) + return res diff --git a/solutions/lesson04/task3.py b/solutions/lesson04/task3.py index 7253f6cbd..89e58fdf8 100644 --- a/solutions/lesson04/task3.py +++ b/solutions/lesson04/task3.py @@ -1,3 +1,6 @@ -def find_single_number(nums: list[int]) -> int: - # ваш код - return 0 +def find_single_number(nums: list[int]) -> int: + res = 0 + + for i in range(len(nums)): + res = res ^ nums[i] + return res diff --git a/solutions/lesson04/task4.py b/solutions/lesson04/task4.py index b21bc5a39..3b80843c7 100644 --- a/solutions/lesson04/task4.py +++ b/solutions/lesson04/task4.py @@ -1,3 +1,11 @@ def move_zeros_to_end(nums: list[int]) -> list[int]: - # ваш код - return 0 \ No newline at end of file + count= 0 #можно ли назвать переменную "K" и в комментарии указать, что она значит? + #или желательно все переменные называть по их предназначению? + for i in range(len(nums)): + if nums[i] != 0: + nums[count], nums[i] = nums[i], nums[count] + count+=1 + + + return count + diff --git a/solutions/lesson04/task5.py b/solutions/lesson04/task5.py index 02d7742bb..63a23e0aa 100644 --- a/solutions/lesson04/task5.py +++ b/solutions/lesson04/task5.py @@ -1,3 +1,16 @@ def find_row_with_most_ones(matrix: list[list[int]]) -> int: - # ваш код - return 0 \ No newline at end of file + maxi = 0 + place = 0 + for i in range(len(matrix)): + matrix[i].reverse() # на семенаре reverse был + sumi = 0 + for j in range(len(matrix[i])): + if matrix[i][j] == 0: + break + sumi += 1 + + if sumi > maxi: + maxi = sumi + place = i + + return place diff --git a/solutions/lesson04/task6.py b/solutions/lesson04/task6.py index 16df27ca6..b7a17bbf4 100644 --- a/solutions/lesson04/task6.py +++ b/solutions/lesson04/task6.py @@ -1,3 +1,13 @@ def count_cycles(arr: list[int]) -> int: - # ваш код - return 0 \ No newline at end of file + cycle = 0 + for i in range(len(arr)): + if arr[i] != -1: + cycle += 1 + + element = arr[i] + while arr[element] != -1: + remember = arr[element] + arr[element] = -1 + element=remember + + return cycle From c4cff890aa0d385d9d49b3935415cafa166387e5 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Thu, 23 Oct 2025 20:49:49 +0300 Subject: [PATCH 05/17] Makarov514 --- solutions/lesson05/task1.py | 4 +++- solutions/lesson05/task2.py | 4 ++-- solutions/lesson05/task3.py | 9 +++++++-- solutions/lesson05/task4.py | 31 +++++++++++++++++++++++++++++-- solutions/lesson05/task5.py | 36 ++++++++++++++++++++++++++++++++++-- solutions/lesson05/task6.py | 24 ++++++++++++++++++++++-- 6 files changed, 97 insertions(+), 11 deletions(-) diff --git a/solutions/lesson05/task1.py b/solutions/lesson05/task1.py index 9a17211e5..af4ca3248 100644 --- a/solutions/lesson05/task1.py +++ b/solutions/lesson05/task1.py @@ -1,3 +1,5 @@ def is_palindrome(text: str) -> bool: - # ваш код + text = text.lower() + if text == text[::-1]: + return True return False \ No newline at end of file diff --git a/solutions/lesson05/task2.py b/solutions/lesson05/task2.py index 367503802..c32c0aef0 100644 --- a/solutions/lesson05/task2.py +++ b/solutions/lesson05/task2.py @@ -1,3 +1,3 @@ def are_anagrams(word1: str, word2: str) -> bool: - # ваш код - return False \ No newline at end of file + + return sorted(word1)==sorted(word2) \ No newline at end of file diff --git a/solutions/lesson05/task3.py b/solutions/lesson05/task3.py index e368e2f49..94aa30b87 100644 --- a/solutions/lesson05/task3.py +++ b/solutions/lesson05/task3.py @@ -1,3 +1,8 @@ def is_punctuation(text: str) -> bool: - # ваш код - return False + alphabet = "!""#$%&'()*+,-./:;<=>?@[\]^_{|}~`" + if text == "": + return False + for sym in text: + if sym not in alphabet: + return False + return True diff --git a/solutions/lesson05/task4.py b/solutions/lesson05/task4.py index 4c4e9086e..a74948b32 100644 --- a/solutions/lesson05/task4.py +++ b/solutions/lesson05/task4.py @@ -1,3 +1,30 @@ def unzip(compress_text: str) -> str: - # ваш код - return compress_text \ No newline at end of file + text = "" + compress_text += " " + pul = "" + k=0 + for i in compress_text: + if i ==" " or i in "0123456789": + text += pul + pul = "" + k += 1 + continue + if i == "*": + ind = 1 + number = 0 + while compress_text[k+ind].isdigit() and k + ind bool: - # ваш код - return False \ No newline at end of file + i = 0 + r = 0 + + while r < len(reg_expr) and i < len(text): + symb = reg_expr[r] + + if symb == 'd': + if not text[i].isdigit(): + return False + while i < len(text) and text[i].isdigit(): + i += 1 + r += 1 + + elif symb == 'w': + if not text[i].isalpha(): + return False + while i < len(text) and text[i].isalpha(): + i += 1 + r += 1 + + elif symb == 's': + if not (text[i].isalpha() or text[i].isdigit()): + return False + while i < len(text) and (text[i].isalpha() or text[i].isdigit()): + i += 1 + r += 1 + + else: + if text[i] != symb: + return False + i += 1 + r += 1 + + return i == len(text) and r == len(reg_expr) diff --git a/solutions/lesson05/task6.py b/solutions/lesson05/task6.py index 1b914ada7..97bf37beb 100644 --- a/solutions/lesson05/task6.py +++ b/solutions/lesson05/task6.py @@ -1,3 +1,23 @@ def simplify_path(path: str) -> str: - # ваш код - return path \ No newline at end of file + components = path.split('/') + stuff = [] + + for comp in components: + if comp == '' or comp == '.': + continue + elif comp == '..': + if stuff != []: + stuff.pop() + else: + return "" + else: + stuff.append(comp) + + path = "/" + for i in range(len(stuff)): + path = path + stuff[i] + '/' + + if stuff == []: + return '/' + return path[:-1] + From 51b932984cc25cd6d4bcedd0c9a2eacc0e2a6ffc Mon Sep 17 00:00:00 2001 From: korolinakila Date: Sat, 1 Nov 2025 20:59:27 +0300 Subject: [PATCH 06/17] B12-514 Makarov Matvey --- solutions/lesson06/task1.py | 16 ++++++++++++++-- solutions/lesson06/task2.py | 12 ++++++++++-- solutions/lesson06/task3.py | 21 ++++++++++++++++++++- solutions/lesson06/task4.py | 9 +++++++-- 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/solutions/lesson06/task1.py b/solutions/lesson06/task1.py index 2d1e30e96..6a4d80d77 100644 --- a/solutions/lesson06/task1.py +++ b/solutions/lesson06/task1.py @@ -1,3 +1,15 @@ def int_to_roman(num: int) -> str: - # ваш код - return "" \ No newline at end of file + rom_dict = { + 1000: 'M', 900: 'CM', 500: 'D', 400: 'CD', + 100: 'C', 90: 'XC', 50: 'L', 40: 'XL', + 10: 'X', 9: 'IX', 5: 'V', 4: 'IV', 1: 'I' + } + + values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] + + res = [] + for value in values: + while num >= value: + result.append(rom_dict[value]) + num -= value + return ''.join(res) diff --git a/solutions/lesson06/task2.py b/solutions/lesson06/task2.py index f535b5a0c..4a0dc9d64 100644 --- a/solutions/lesson06/task2.py +++ b/solutions/lesson06/task2.py @@ -1,3 +1,11 @@ def get_len_of_longest_substring(text: str) -> int: - # ваш код - return 0 \ No newline at end of file + res = "" + maxi = 0 + for i in range(len(text)): + if text[i] not in res: + res += text[i] + else: + maxi = max(maxi, len(res)) + res = res[res.find(text[i])+1:] + text[i] + maxi = max(maxi, len(res)) + return maxi diff --git a/solutions/lesson06/task3.py b/solutions/lesson06/task3.py index 7449a1e72..75b5c1480 100644 --- a/solutions/lesson06/task3.py +++ b/solutions/lesson06/task3.py @@ -2,6 +2,25 @@ def is_there_any_good_subarray( nums: list[int], k: int, ) -> bool: + arr_ost = [0] + next_sum = 0 + + for i in range(len(nums)): + next_sum += nums[i] + ost = next_sum % k + + if ost in arr_ost: + print(arr_ost.index(ost), i, arr_ost) + if i - arr_ost.index(ost) >= 2: + return True + else: + arr_ost.append(ost) + + else: + arr_ost.append(ost) + + if (len(arr_ost) - 1) - arr_ost.index(arr_ost[-1]) >= 2: + return True - # ваш код return False + diff --git a/solutions/lesson06/task4.py b/solutions/lesson06/task4.py index 5b75a110c..beb59265f 100644 --- a/solutions/lesson06/task4.py +++ b/solutions/lesson06/task4.py @@ -1,3 +1,8 @@ def count_unique_words(text: str) -> int: - # ваш код - return 0 \ No newline at end of file + text = text.lower() + res = "" + for i in range(len(text)): + if (text[i] >= 'a' and text[i] <= 'z') or (text[i] >= '0' and text[i] <= '9') or text[i] == " ": + res += text[i] + + return len(set(res.split())) From b563b4b4df8720a4e0464ce6ee9927f273b0a698 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Sat, 15 Nov 2025 00:47:46 +0300 Subject: [PATCH 07/17] Makarov514 --- .vscode/c_cpp_properties.json | 21 ++++ .vscode/settings.json | 3 +- CMakeLists.txt | 5 + CMakePresets.json | 17 +++ main.cpp | 5 + .../api/v1/query/client-vscode/query.json | 1 + .../reply/error-2025-11-13T18-38-03-0559.json | 70 +++++++++++ .../reply/error-2025-11-14T12-28-49-0106.json | 70 +++++++++++ .../reply/error-2025-11-14T20-08-20-0354.json | 70 +++++++++++ .../reply/error-2025-11-14T20-43-41-0618.json | 70 +++++++++++ .../reply/error-2025-11-14T20-49-20-0252.json | 70 +++++++++++ .../CMakeCache.txt | 115 ++++++++++++++++++ .../CMakeFiles/4.1.2/CMakeSystem.cmake | 15 +++ .../CMakeFiles/CMakeConfigureLog.yaml | 55 +++++++++ .../CMakeFiles/cmake.check_cache | 1 + solutions/lesson08/task1.py | 11 +- 16 files changed, 596 insertions(+), 3 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 CMakeLists.txt create mode 100644 CMakePresets.json create mode 100644 main.cpp create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/query/client-vscode/query.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-13T18-38-03-0559.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T12-28-49-0106.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-08-20-0354.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-43-41-0618.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-49-20-0252.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeCache.txt create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/4.1.2/CMakeSystem.cmake create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/cmake.check_cache diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 000000000..916dae4e4 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "compilerPath": "C:\\Users\\Matvey\\gcc\\bin\\gcc.exe", + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "windows-gcc-x64", + "configurationProvider": "ms-vscode.cmake-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 9b388533a..c20e25e03 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "tests" ], "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "C_Cpp.errorSquiggles": "enabled" } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..2f7297cfc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.10.0) +project(main VERSION 0.1.0 LANGUAGES C CXX) + +add_executable(main main.cpp) + diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..cd8ac89b0 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,17 @@ +{ + "version": 8, + "configurePresets": [ + { + "name": "GCC 15.2.0 x86_64-w64-mingw32", + "displayName": "GCC 15.2.0 x86_64-w64-mingw32", + "description": "Using compilers: C = C:\\Users\\Matvey\\gcc\\bin\\gcc.exe, CXX = C:\\Users\\Matvey\\gcc\\bin\\g++.exe", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_C_COMPILER": "C:/Users/Matvey/gcc/bin/gcc.exe", + "CMAKE_CXX_COMPILER": "C:/Users/Matvey/gcc/bin/g++.exe", + "CMAKE_BUILD_TYPE": "Debug" + } + } + ] +} \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 000000000..f4b0d626d --- /dev/null +++ b/main.cpp @@ -0,0 +1,5 @@ +#include + +int main(int, char**){ + std::cout << "Hello, from main!\n"; +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/query/client-vscode/query.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/query/client-vscode/query.json new file mode 100644 index 000000000..82bb96424 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/query/client-vscode/query.json @@ -0,0 +1 @@ +{"requests":[{"kind":"cache","version":2},{"kind":"codemodel","version":2},{"kind":"toolchains","version":1},{"kind":"cmakeFiles","version":1}]} \ No newline at end of file diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-13T18-38-03-0559.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-13T18-38-03-0559.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-13T18-38-03-0559.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T12-28-49-0106.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T12-28-49-0106.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T12-28-49-0106.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-08-20-0354.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-08-20-0354.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-08-20-0354.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-43-41-0618.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-43-41-0618.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-43-41-0618.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-49-20-0252.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-49-20-0252.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-14T20-49-20-0252.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeCache.txt b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeCache.txt new file mode 100644 index 000000000..aa8f3d4ec --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeCache.txt @@ -0,0 +1,115 @@ +# This is the CMakeCache file. +# For build in directory: d:/VSprojects/python_mipt_dafe_tasks/out/build/GCC 15.2.0 x86_64-w64-mingw32 +# It was generated by CMake: C:/Program Files/CMake/bin/cmake.exe +# You can edit this file to change values found and used by cmake. +# If you do not want to change any of the values, simply exit the editor. +# If you do want to change a value, simply edit, save, and exit the editor. +# The syntax for the file is as follows: +# KEY:TYPE=VALUE +# KEY is the name of a variable in the cache. +# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!. +# VALUE is the current value for the KEY. + +######################## +# EXTERNAL cache entries +######################## + +//No help, variable specified on the command line. +CMAKE_BUILD_TYPE:UNINITIALIZED=Debug + +//No help, variable specified on the command line. +CMAKE_CXX_COMPILER:UNINITIALIZED=C:/Users/Matvey/gcc/bin/g++.exe + +//No help, variable specified on the command line. +CMAKE_C_COMPILER:UNINITIALIZED=C:/Users/Matvey/gcc/bin/gcc.exe + +//Value Computed by CMake. +CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=D:/VSprojects/python_mipt_dafe_tasks/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/pkgRedirects + +//No help, variable specified on the command line. +CMAKE_INSTALL_PREFIX:UNINITIALIZED=D:/VSprojects/python_mipt_dafe_tasks/out/install/GCC 15.2.0 x86_64-w64-mingw32 + +//Program used to build from makefiles. +CMAKE_MAKE_PROGRAM:STRING=nmake + +//Value Computed by CMake +CMAKE_PROJECT_COMPAT_VERSION:STATIC= + +//Value Computed by CMake +CMAKE_PROJECT_DESCRIPTION:STATIC= + +//Value Computed by CMake +CMAKE_PROJECT_HOMEPAGE_URL:STATIC= + +//Value Computed by CMake +CMAKE_PROJECT_NAME:STATIC=main + +//Value Computed by CMake +CMAKE_PROJECT_VERSION:STATIC=0.1.0 + +//Value Computed by CMake +CMAKE_PROJECT_VERSION_MAJOR:STATIC=0 + +//Value Computed by CMake +CMAKE_PROJECT_VERSION_MINOR:STATIC=1 + +//Value Computed by CMake +CMAKE_PROJECT_VERSION_PATCH:STATIC=0 + +//Value Computed by CMake +CMAKE_PROJECT_VERSION_TWEAK:STATIC= + +//Value Computed by CMake +main_BINARY_DIR:STATIC=D:/VSprojects/python_mipt_dafe_tasks/out/build/GCC 15.2.0 x86_64-w64-mingw32 + +//Value Computed by CMake +main_IS_TOP_LEVEL:STATIC=ON + +//Value Computed by CMake +main_SOURCE_DIR:STATIC=D:/VSprojects/python_mipt_dafe_tasks + + +######################## +# INTERNAL cache entries +######################## + +//This is the directory where this CMakeCache.txt was created +CMAKE_CACHEFILE_DIR:INTERNAL=d:/VSprojects/python_mipt_dafe_tasks/out/build/GCC 15.2.0 x86_64-w64-mingw32 +//Major version of cmake used to create the current loaded cache +CMAKE_CACHE_MAJOR_VERSION:INTERNAL=4 +//Minor version of cmake used to create the current loaded cache +CMAKE_CACHE_MINOR_VERSION:INTERNAL=1 +//Patch version of cmake used to create the current loaded cache +CMAKE_CACHE_PATCH_VERSION:INTERNAL=2 +//Path to CMake executable. +CMAKE_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake.exe +//Path to cpack program executable. +CMAKE_CPACK_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cpack.exe +//Path to ctest program executable. +CMAKE_CTEST_COMMAND:INTERNAL=C:/Program Files/CMake/bin/ctest.exe +//Path to cache edit program executable. +CMAKE_EDIT_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake-gui.exe +//Name of external makefile project generator. +CMAKE_EXTRA_GENERATOR:INTERNAL= +//Name of generator. +CMAKE_GENERATOR:INTERNAL=NMake Makefiles +//Generator instance identifier. +CMAKE_GENERATOR_INSTANCE:INTERNAL= +//Name of generator platform. +CMAKE_GENERATOR_PLATFORM:INTERNAL= +//Name of generator toolset. +CMAKE_GENERATOR_TOOLSET:INTERNAL= +//Source directory with the top level CMakeLists.txt file for this +// project +CMAKE_HOME_DIRECTORY:INTERNAL=D:/VSprojects/python_mipt_dafe_tasks +//Name of CMakeLists files to read +CMAKE_LIST_FILE_NAME:INTERNAL=CMakeLists.txt +//ADVANCED property for variable: CMAKE_MAKE_PROGRAM +CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1 +//number of local generators +CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1 +//Platform information initialized +CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1 +//Path to CMake installation. +CMAKE_ROOT:INTERNAL=C:/Program Files/CMake/share/cmake-4.1 + diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/4.1.2/CMakeSystem.cmake b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/4.1.2/CMakeSystem.cmake new file mode 100644 index 000000000..909db20dc --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/4.1.2/CMakeSystem.cmake @@ -0,0 +1,15 @@ +set(CMAKE_HOST_SYSTEM "Windows-10.0.19045") +set(CMAKE_HOST_SYSTEM_NAME "Windows") +set(CMAKE_HOST_SYSTEM_VERSION "10.0.19045") +set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64") + + + +set(CMAKE_SYSTEM "Windows-10.0.19045") +set(CMAKE_SYSTEM_NAME "Windows") +set(CMAKE_SYSTEM_VERSION "10.0.19045") +set(CMAKE_SYSTEM_PROCESSOR "AMD64") + +set(CMAKE_CROSSCOMPILING "FALSE") + +set(CMAKE_SYSTEM_LOADED 1) diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml new file mode 100644 index 000000000..110ba4071 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml @@ -0,0 +1,55 @@ + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/cmake.check_cache b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/cmake.check_cache new file mode 100644 index 000000000..3dccd7317 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/cmake.check_cache @@ -0,0 +1 @@ +# This file is generated by cmake for dependency checking of the CMakeCache.txt file diff --git a/solutions/lesson08/task1.py b/solutions/lesson08/task1.py index 4390f6c84..0ff81274a 100644 --- a/solutions/lesson08/task1.py +++ b/solutions/lesson08/task1.py @@ -1,5 +1,12 @@ from typing import Callable def make_averager(accumulation_period: int) -> Callable[[float], float]: - # ваш код - pass \ No newline at end of file + values = [] + + def get_avg(value: float) -> float: + values.append(value) + if len(values) > accumulation_period: + values.pop(0) + return sum(values) / len(values) + + return get_avg From e5749242f016c719b4cf8cf9c754467166ae3cb0 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Sat, 15 Nov 2025 12:59:27 +0300 Subject: [PATCH 08/17] Makarov514 --- .../reply/error-2025-11-15T08-33-39-0670.json | 70 +++++++++++++++++++ .../reply/error-2025-11-15T09-18-59-0647.json | 70 +++++++++++++++++++ .../reply/error-2025-11-15T09-38-16-0304.json | 70 +++++++++++++++++++ .../CMakeFiles/CMakeConfigureLog.yaml | 33 +++++++++ solutions/lesson06/task1.py | 2 +- solutions/lesson08/task1.py | 2 +- solutions/lesson08/task2.py | 2 +- 7 files changed, 246 insertions(+), 3 deletions(-) create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T08-33-39-0670.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-18-59-0647.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-38-16-0304.json diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T08-33-39-0670.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T08-33-39-0670.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T08-33-39-0670.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-18-59-0647.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-18-59-0647.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-18-59-0647.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-38-16-0304.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-38-16-0304.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T09-38-16-0304.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml index 110ba4071..8d5985421 100644 --- a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml @@ -53,3 +53,36 @@ events: message: | The system is: Windows - 10.0.19045 - AMD64 ... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... diff --git a/solutions/lesson06/task1.py b/solutions/lesson06/task1.py index 6a4d80d77..f204b65f9 100644 --- a/solutions/lesson06/task1.py +++ b/solutions/lesson06/task1.py @@ -10,6 +10,6 @@ def int_to_roman(num: int) -> str: res = [] for value in values: while num >= value: - result.append(rom_dict[value]) + res.append(rom_dict[value]) num -= value return ''.join(res) diff --git a/solutions/lesson08/task1.py b/solutions/lesson08/task1.py index 0ff81274a..5af0aaaf3 100644 --- a/solutions/lesson08/task1.py +++ b/solutions/lesson08/task1.py @@ -9,4 +9,4 @@ def get_avg(value: float) -> float: values.pop(0) return sum(values) / len(values) - return get_avg + return get_avg \ No newline at end of file diff --git a/solutions/lesson08/task2.py b/solutions/lesson08/task2.py index 6e4af8707..181a7af56 100644 --- a/solutions/lesson08/task2.py +++ b/solutions/lesson08/task2.py @@ -7,4 +7,4 @@ def collect_statistic( ) -> Callable[[T], T]: # ваш код - pass \ No newline at end of file + pass From 0afa7d9c507ba3e702812f41c030a71477a7e11c Mon Sep 17 00:00:00 2001 From: korolinakila Date: Sun, 30 Nov 2025 10:23:56 +0300 Subject: [PATCH 09/17] HW1 --- CMakeLists.txt | 5 -- CMakePresets.json | 17 ---- homeworks/hw1/aggregate_segmentation.py | 81 ++++++++++++++++++- homeworks/hw1/backoff.py | 46 ++++++++++- homeworks/hw1/cache.py | 69 +++++++++++++++- homeworks/hw1/convert_exception.py | 16 +++- main.cpp | 5 -- .../reply/error-2025-11-15T10-01-37-0424.json | 70 ++++++++++++++++ .../reply/error-2025-11-15T10-57-19-0060.json | 70 ++++++++++++++++ .../reply/error-2025-11-20T12-57-48-0090.json | 70 ++++++++++++++++ .../reply/error-2025-11-20T13-31-38-0525.json | 70 ++++++++++++++++ .../reply/error-2025-11-20T15-45-19-0012.json | 70 ++++++++++++++++ .../reply/error-2025-11-20T18-15-15-0126.json | 70 ++++++++++++++++ .../CMakeFiles/CMakeConfigureLog.yaml | 55 +++++++++++++ solutions/lesson08/task2.py | 18 +++++ 15 files changed, 696 insertions(+), 36 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 CMakePresets.json delete mode 100644 main.cpp create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-01-37-0424.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-57-19-0060.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T12-57-48-0090.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T13-31-38-0525.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T15-45-19-0012.json create mode 100644 out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T18-15-15-0126.json diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 2f7297cfc..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 3.10.0) -project(main VERSION 0.1.0 LANGUAGES C CXX) - -add_executable(main main.cpp) - diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index cd8ac89b0..000000000 --- a/CMakePresets.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": 8, - "configurePresets": [ - { - "name": "GCC 15.2.0 x86_64-w64-mingw32", - "displayName": "GCC 15.2.0 x86_64-w64-mingw32", - "description": "Using compilers: C = C:\\Users\\Matvey\\gcc\\bin\\gcc.exe, CXX = C:\\Users\\Matvey\\gcc\\bin\\g++.exe", - "binaryDir": "${sourceDir}/out/build/${presetName}", - "cacheVariables": { - "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", - "CMAKE_C_COMPILER": "C:/Users/Matvey/gcc/bin/gcc.exe", - "CMAKE_CXX_COMPILER": "C:/Users/Matvey/gcc/bin/g++.exe", - "CMAKE_BUILD_TYPE": "Debug" - } - } - ] -} \ No newline at end of file diff --git a/homeworks/hw1/aggregate_segmentation.py b/homeworks/hw1/aggregate_segmentation.py index 1cdc176af..4d3f35334 100644 --- a/homeworks/hw1/aggregate_segmentation.py +++ b/homeworks/hw1/aggregate_segmentation.py @@ -3,7 +3,7 @@ "voice_human", "voice_bot", } - +print("AAAAAAAAAAAAAAAAAAAAAAAAAa") def aggregate_segmentation( segmentation_data: list[dict[str, str | float | None]], @@ -24,5 +24,80 @@ def aggregate_segmentation( Список `audio_id` (str), которые требуют переразметки. """ - # ваш код - return {}, [] + valid_data = {} + audio_ids_with_errors = tuple() + segment_cache = {} + + + + for segment in segmentation_data: + + if "segment_id" not in segment or segment["segment_id"] is None: + continue + + if "audio_id" not in segment or segment["audio_id"] is None: + continue + + audio_id = segment["audio_id"] + segment_id = segment["segment_id"] + + + is_valid = True + + + if not isinstance(segment_id, str): + is_valid = False + if not isinstance(audio_id, str): + is_valid = False + + + type_val = segment.get("type") + start_val = segment.get("segment_start") + end_val = segment.get("segment_end") + + none_count = 0 + for i in [type_val, start_val, end_val]: + if i is None: + none_count += 1 + + if none_count == 1 or none_count == 2: + + is_valid = False + elif none_count == 0: + + if not isinstance(type_val, str): + is_valid = False + elif type_val not in ALLOWED_TYPES: + is_valid = False + + if not isinstance(start_val, float): + is_valid = False + if not isinstance(end_val, float): + is_valid = False + + + if not is_valid: + audio_ids_with_errors = tuple(list(audio_ids_with_errors) + [audio_id]) + else: + if none_count == 0: + if audio_id not in valid_data: + valid_data[audio_id] = {} + + valid_data[audio_id][segment_id] = { + "start": start_val, + "end": end_val, + "type": type_val + } + elif none_count == 3: + if audio_id not in valid_data: + valid_data[audio_id] = {} + + + + + for audio_id in list(valid_data.keys()): + if audio_id in audio_ids_with_errors: + del valid_data[audio_id] + + + return valid_data, audio_ids_with_errors diff --git a/homeworks/hw1/backoff.py b/homeworks/hw1/backoff.py index 696ffa73a..ed2c0c9af 100644 --- a/homeworks/hw1/backoff.py +++ b/homeworks/hw1/backoff.py @@ -34,5 +34,47 @@ def backoff( ValueError, если были переданы невозможные аргументы. """ - # ваш код - pass + if retry_amount < 1 or retry_amount > 100: + raise ValueError("retry_amount должен быть в диапазоне от 1 до 100") + + if timeout_start <= 0 or timeout_start >= 10: + raise ValueError("timeout_start должен быть в диапазоне (0, 10)") + + if timeout_max <= 0 or timeout_max >= 10: + raise ValueError("timeout_max должен быть в диапазоне (0, 10)") + + if backoff_scale <= 0 or backoff_scale >= 10: + raise ValueError("backoff_scale должен быть в диапазоне (0, 10)") + + if not backoff_triggers: + raise ValueError("backoff_triggers не может быть пустым") + + def decorator(func: Callable[P, R]) -> Callable[P, R]: + def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: + last_exception = None + current_timeout = timeout_start + + for trying in range(retry_amount): + try: + return func(*args, **kwargs) + except Exception as e: + last_exception = e + + should_retry = any(isinstance(e, trigger) for trigger in backoff_triggers) + + if not should_retry or trying == retry_amount - 1: + + raise last_exception + + jitter = uniform(0, 0.5) + total_sleep_time = min(current_timeout + jitter, timeout_max) + + sleep(total_sleep_time) + + current_timeout = min(current_timeout * backoff_scale, timeout_max) + + raise last_exception + + return wrapper + + return decorator \ No newline at end of file diff --git a/homeworks/hw1/cache.py b/homeworks/hw1/cache.py index 9eb1d5d2d..573317439 100644 --- a/homeworks/hw1/cache.py +++ b/homeworks/hw1/cache.py @@ -23,5 +23,70 @@ def lru_cache(capacity: int) -> Callable[[Callable[P, R]], Callable[P, R]]: для получения целого числа. ValueError, если после округления capacity - число, меньшее 1. """ - # ваш код - pass + try: + capacity = round(capacity) + except (TypeError, ValueError) as e: + raise TypeError + + if capacity < 1: + raise ValueError + + def decorator(func: Callable[P, R]) -> Callable[P, R]: + class Node: + def __init__(self, key, value): + self.key = key + self.value = value + self.prev = None + self.next = None + + cache = {} + head = Node(None, None) + tail = Node(None, None) + head.next = tail + tail.prev = head + + def remove_node(node: Node): + """Удаляет узел из двусвязного списка""" + prev_node = node.prev + next_node = node.next + prev_node.next = next_node + next_node.prev = prev_node + + def add_to_front(node: Node): + """Добавляет узел в начало списка (после head)""" + first_node = head.next + head.next = node + node.prev = head + node.next = first_node + first_node.prev = node + + def move_to_front(node: Node): + """Перемещает узел в начало списка""" + remove_node(node) + add_to_front(node) + + def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: + key = (args, tuple(sorted(kwargs.items()))) + + if key in cache: + node = cache[key] + move_to_front(node) + return node.value + else: + result = func(*args, **kwargs) + + new_node = Node(key, result) + + if len(cache) >= capacity: + lru_node = tail.prev + remove_node(lru_node) + del cache[lru_node.key] + + add_to_front(new_node) + cache[key] = new_node + + return result + + return wrapper + + return decorator \ No newline at end of file diff --git a/homeworks/hw1/convert_exception.py b/homeworks/hw1/convert_exception.py index fe5c770fd..8626ead53 100644 --- a/homeworks/hw1/convert_exception.py +++ b/homeworks/hw1/convert_exception.py @@ -24,5 +24,17 @@ def convert_exceptions_to_api_compitable_ones( Декоратор для непосредственного использования. """ - # ваш код - pass + def decorator(func: Callable[P, R]) -> Callable[P, R]: + def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: + try: + return func(*args, **kwargs) + except Exception as e: + for exception_type, api_exception in exception_to_api_exception.items(): + if isinstance(e, exception_type): + raise api_exception() + + raise + + return wrapper + + return decorator \ No newline at end of file diff --git a/main.cpp b/main.cpp deleted file mode 100644 index f4b0d626d..000000000 --- a/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main(int, char**){ - std::cout << "Hello, from main!\n"; -} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-01-37-0424.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-01-37-0424.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-01-37-0424.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-57-19-0060.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-57-19-0060.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-15T10-57-19-0060.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T12-57-48-0090.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T12-57-48-0090.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T12-57-48-0090.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T13-31-38-0525.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T13-31-38-0525.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T13-31-38-0525.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T15-45-19-0012.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T15-45-19-0012.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T15-45-19-0012.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T18-15-15-0126.json b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T18-15-15-0126.json new file mode 100644 index 000000000..27bf3c2c5 --- /dev/null +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/.cmake/api/v1/reply/error-2025-11-20T18-15-15-0126.json @@ -0,0 +1,70 @@ +{ + "cmake" : + { + "generator" : + { + "multiConfig" : false, + "name" : "NMake Makefiles" + }, + "paths" : + { + "cmake" : "C:/Program Files/CMake/bin/cmake.exe", + "cpack" : "C:/Program Files/CMake/bin/cpack.exe", + "ctest" : "C:/Program Files/CMake/bin/ctest.exe", + "root" : "C:/Program Files/CMake/share/cmake-4.1" + }, + "version" : + { + "isDirty" : false, + "major" : 4, + "minor" : 1, + "patch" : 2, + "string" : "4.1.2", + "suffix" : "" + } + }, + "objects" : [], + "reply" : + { + "client-vscode" : + { + "query.json" : + { + "requests" : + [ + { + "kind" : "cache", + "version" : 2 + }, + { + "kind" : "codemodel", + "version" : 2 + }, + { + "kind" : "toolchains", + "version" : 1 + }, + { + "kind" : "cmakeFiles", + "version" : 1 + } + ], + "responses" : + [ + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + }, + { + "error" : "no buildsystem generated" + } + ] + } + } + } +} diff --git a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml index 8d5985421..f36e049ca 100644 --- a/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml +++ b/out/build/GCC 15.2.0 x86_64-w64-mingw32/CMakeFiles/CMakeConfigureLog.yaml @@ -86,3 +86,58 @@ events: message: | The system is: Windows - 10.0.19045 - AMD64 ... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... + +--- +events: + - + kind: "message-v1" + backtrace: + - "C:/Program Files/CMake/share/cmake-4.1/Modules/CMakeDetermineSystem.cmake:212 (message)" + - "CMakeLists.txt:2 (project)" + message: | + The system is: Windows - 10.0.19045 - AMD64 +... diff --git a/solutions/lesson08/task2.py b/solutions/lesson08/task2.py index 181a7af56..87e72fa7c 100644 --- a/solutions/lesson08/task2.py +++ b/solutions/lesson08/task2.py @@ -1,3 +1,4 @@ +import time from typing import Callable, TypeVar T = TypeVar("T") @@ -5,6 +6,23 @@ def collect_statistic( statistics: dict[str, list[float, int]] ) -> Callable[[T], T]: + def decor(func: Calable) -> Callable: + @wraps(func) + def wrapper(*args, **kwargs): + start_time = time.time() + res = func(*args, **kwargs) + end_time = time.time() + + statistics.setdefault(func.__name__, [0, 0]) + count = statistics[func.__name__][1] + statistics[func.__name__][0] = count * statistics[func.__name__][0] + end_time - start_time + statistics[func.__name__][0] /= count + 1 + statistics[func.__name__][1] += 1 + + return res + + return wrapper + return decor # ваш код pass From ab0d325d0b71998bad7ac60fe045b370b9a40778 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Sun, 30 Nov 2025 10:33:06 +0300 Subject: [PATCH 10/17] HW1 --- homeworks/hw1/aggregate_segmentation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeworks/hw1/aggregate_segmentation.py b/homeworks/hw1/aggregate_segmentation.py index 4d3f35334..62117ddd0 100644 --- a/homeworks/hw1/aggregate_segmentation.py +++ b/homeworks/hw1/aggregate_segmentation.py @@ -3,7 +3,6 @@ "voice_human", "voice_bot", } -print("AAAAAAAAAAAAAAAAAAAAAAAAAa") def aggregate_segmentation( segmentation_data: list[dict[str, str | float | None]], From 477ecf377e2db71dc84de730eb4cc49366d86438 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Sun, 7 Dec 2025 04:04:29 +0300 Subject: [PATCH 11/17] lesson11 --- homeworks/hw1/test_segmentation.py | 146 +++++++++++++++++++++++++++++ solutions/lesson11/task1.py | 127 ++++++++++++++++++++++++- 2 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 homeworks/hw1/test_segmentation.py diff --git a/homeworks/hw1/test_segmentation.py b/homeworks/hw1/test_segmentation.py new file mode 100644 index 000000000..a88237c01 --- /dev/null +++ b/homeworks/hw1/test_segmentation.py @@ -0,0 +1,146 @@ +ALLOWED_TYPES = { + "spotter_word", + "voice_human", + "voice_bot", +} + +def aggregate_segmentation( + segmentation_data: list[dict[str, str | float | None]], +) -> tuple[dict[str, dict[str, dict[str, str | float]]], list[str]]: + """ + Функция для валидации и агрегации данных разметки аудио сегментов. + + Args: + segmentation_data: словарь, данные разметки аудиосегментов с полями: + "audio_id" - уникальный идентификатор аудио. + "segment_id" - уникальный идентификатор сегмента. + "segment_start" - время начала сегмента. + "segment_end" - время окончания сегмента. + "type" - тип голоса в сегменте. + + Returns: + Словарь с валидными сегментами, объединёнными по `audio_id`; + Список `audio_id` (str), которые требуют переразметки. + """ + + valid_data = {} + audio_ids_with_errors = tuple() + segment_cache = {} + + + + for segment in segmentation_data: + + if "segment_id" not in segment or segment["segment_id"] is None: + continue + + if "audio_id" not in segment or segment["audio_id"] is None: + continue + + audio_id = segment["audio_id"] + segment_id = segment["segment_id"] + + + is_valid = True + + + if not isinstance(segment_id, str): + is_valid = False + if not isinstance(audio_id, str): + is_valid = False + + + type_val = segment.get("type") + start_val = segment.get("segment_start") + end_val = segment.get("segment_end") + + none_count = 0 + for i in [type_val, start_val, end_val]: + if i is None: + none_count += 1 + + if none_count == 1 or none_count == 2: + + is_valid = False + elif none_count == 0: + + if not isinstance(type_val, str): + is_valid = False + elif type_val not in ALLOWED_TYPES: + is_valid = False + + if not isinstance(start_val, float): + is_valid = False + if not isinstance(end_val, float): + is_valid = False + + + if not is_valid: + audio_ids_with_errors = tuple(list(audio_ids_with_errors) + [audio_id]) + else: + if none_count == 0: + if audio_id not in valid_data: + valid_data[audio_id] = {} + + valid_data[audio_id][segment_id] = { + "start": start_val, + "end": end_val, + "type": type_val + } + elif none_count == 3: + if audio_id not in valid_data: + valid_data[audio_id] = {} + + + + + for audio_id in list(valid_data.keys()): + if audio_id in audio_ids_with_errors: + del valid_data[audio_id] + + + return valid_data, audio_ids_with_errors + + +def test_aggregate_segmentation_with_invalid_type_after_valid_detailed(): + """Тест с дополнительными проверками состояния до и после невалидного сегмента""" + segmentation_data = [ + { + "audio_id": "audio_1", + "segment_id": "segment_1", + "segment_start": 0.0, + "segment_end": 1.0, + "type": "voice_human" + }, + { + "audio_id": "audio_2", # Другой валидный audio_id + "segment_id": "segment_3", + "segment_start": 0.0, + "segment_end": 1.0, + "type": "voice_bot" + }, + { + "audio_id": "audio_1", # Невалидный сегмент + "segment_id": "segment_2", + "segment_start": 1.0, + "segment_end": 2.0, + "type": "invalid_type" + } + ] + + valid_result, invalid_result = aggregate_segmentation(segmentation_data) + + # audio_1 должен быть в невалидных + assert "audio_1" in invalid_result + # audio_1 не должно быть в валидных + assert "audio_1" not in valid_result + # audio_2 должен остаться валидным + assert "audio_2" in valid_result + # В audio_2 должен быть один сегмент + assert len(valid_result["audio_2"]) == 1 + # Проверяем содержимое сегмента audio_2 + assert valid_result["audio_2"]["segment_3"] == { + "start": 0.0, + "end": 1.0, + "type": "voice_bot" + } \ No newline at end of file diff --git a/solutions/lesson11/task1.py b/solutions/lesson11/task1.py index 6a15f31fb..255797f3a 100644 --- a/solutions/lesson11/task1.py +++ b/solutions/lesson11/task1.py @@ -1,10 +1,129 @@ +import math + class Vector2D: + + def conj(self) -> "Vector2D": # ваш код - return Vector2D() + return Vector2D(self.abscissa, (self.ordinate)*(-1)) def get_angle(self, other: "Vector2D") -> float: - # ваш код - return 0 + if isinstance(other, Vector2D): + if self == Vector2D() or other == Vector2D(): + raise ValueError + return math.acos((self @ other)/(abs(self)*abs(other))) + raise TypeError + + def __init__(self, abscissa: float = 0.0, ordinate: float = 0.0): + self._abscissa = float(abscissa) + self._ordinate = float(ordinate) + + @property + def abscissa(self) -> float: + return self._abscissa + + @property + def ordinate(self) -> float: + return self._ordinate + + def __repr__(self) -> str: + x = int(self._abscissa) if self._abscissa == int(self._abscissa) else self._abscissa + y = int(self._ordinate) if self._ordinate == int(self._ordinate) else self._ordinate + return f"Vector2D(abscissa={x}, ordinate={y})" + + def __eq__(self, other: 'Vector2D') -> bool: + if not isinstance(other, Vector2D): + return False + return (math.isclose(self.ordinate, other.ordinate) and math.isclose(self.abscissa, other.abscissa)) + + def __ne__(self, other: 'Vector2D') -> bool: + return not (self == other) + + def __lt__(self, other: 'Vector2D') -> bool: + if not isinstance(other, Vector2D): + return NotImplemented + if not math.isclose(self.abscissa, other.abscissa): + return self.abscissa < other.abscissa + elif not math.isclose(self.ordinate, other.ordinate): + return self.ordinate < other.ordinate + return False + + def __le__(self, other: 'Vector2D') -> bool: + if not isinstance(other, Vector2D): + return NotImplemented + return (self < other or self == other) + + def __gt__(self, other: 'Vector2D') -> bool: + if not isinstance(other, Vector2D): + return NotImplemented + if not math.isclose(self.abscissa, other.abscissa): + return self.abscissa > other.abscissa + elif not math.isclose(self.ordinate, other.ordinate): + return self.ordinate > other.ordinate + return False + + def __ge__(self, other: 'Vector2D') -> bool: + if not isinstance(other, Vector2D): + return NotImplemented + return (self > other or self == other) + + def __abs__(self) -> float: + return (self.abscissa**2 + self.ordinate**2)**0.5 + + def __bool__(self) -> bool: + return not (math.isclose(self.abscissa, 0) and math.isclose(self.ordinate, 0)) + + def __mul__(self, scalar: float): + if isinstance(scalar, Vector2D): + return NotImplemented + return Vector2D(self.abscissa * scalar, self.ordinate * scalar) + + def __rmul__(self, scalar: float): + if isinstance(scalar, Vector2D): + return NotImplemented + return Vector2D(self.abscissa * scalar, self.ordinate * scalar) + + def __truediv__(self, scalar: float): + return Vector2D(self.abscissa / scalar, self.ordinate / scalar) + + def __add__(self, other): + if isinstance(other, Vector2D): + return Vector2D(round(self.abscissa + other.abscissa, 5), round(self.ordinate + other.ordinate, 5)) + return Vector2D(round(self.abscissa + other, 5), round(self.ordinate + other, 5)) + + def __radd__(self, other): + if isinstance(other, Vector2D): + return Vector2D(round(self.abscissa + other.abscissa, 5), round(self.ordinate + other.ordinate, 5)) + if isinstance(other, (int, float)): + return Vector2D(round(self.abscissa + other, 5), round(self.ordinate + other, 5)) + return NotImplemented + + def __sub__(self, other): + if isinstance(other, Vector2D): + return Vector2D(round(self.abscissa - other.abscissa, 5), round(self.ordinate - other.ordinate, 5)) + if isinstance(other, (int, float)): + return Vector2D(round(self.abscissa - other, 5), round(self.ordinate - other, 5)) + return NotImplemented - # ваш код + def __rsub__(self, other): + if isinstance(other, Vector2D): + return Vector2D(round(self.abscissa - other.abscissa, 5), round(self.ordinate - other.ordinate, 5)) + + return NotImplemented + + def __neg__(self): + return Vector2D(-self.abscissa, -self.ordinate) + + def __float__(self) -> float: + return abs(self) + + def __int__(self) -> float: + return int(abs(self)) + + def __complex__(self) -> complex: + return complex(self.abscissa, self.ordinate) + + def __matmul__(self, other: 'Vector2D'): + if isinstance(other, Vector2D): + return (self.abscissa * other.abscissa + self.ordinate * other.ordinate) + return NotImplemented From 0cc503c8ef96960cd5838f0f842ca96750690cca Mon Sep 17 00:00:00 2001 From: korolinakila Date: Thu, 11 Dec 2025 19:13:07 +0300 Subject: [PATCH 12/17] lesson12 --- solutions/lesson12/task1.py | 17 +++++++++++++++-- solutions/lesson12/task2.py | 15 +++++++++++++-- solutions/lesson12/task3.py | 17 ++++++++++++++--- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/solutions/lesson12/task1.py b/solutions/lesson12/task1.py index d1bb828c1..bba337579 100644 --- a/solutions/lesson12/task1.py +++ b/solutions/lesson12/task1.py @@ -1,6 +1,19 @@ + from typing import Any, Generator, Iterable def chunked(iterable: Iterable, size: int) -> Generator[tuple[Any], None, None]: - # ваш код - ... + + iterator = iter(iterable) + + while True: + chunk = [] + try: + for i in range(size): + chunk.append(next(iterator)) + except StopIteration: + if chunk: + yield tuple(chunk) + break + + yield tuple(chunk) diff --git a/solutions/lesson12/task2.py b/solutions/lesson12/task2.py index 3ad802ee7..d9239b38f 100644 --- a/solutions/lesson12/task2.py +++ b/solutions/lesson12/task2.py @@ -2,5 +2,16 @@ def circle(iterable: Iterable) -> Generator[Any, None, None]: - # ваш код - ... + cache = [] + + for item in iterable: + cache.append(item) + yield item + + if not cache: + return + + index = 0 + while True: + yield cache[index] + index = (index + 1) % len(cache) \ No newline at end of file diff --git a/solutions/lesson12/task3.py b/solutions/lesson12/task3.py index 64c112ccc..108a54de3 100644 --- a/solutions/lesson12/task3.py +++ b/solutions/lesson12/task3.py @@ -6,7 +6,18 @@ def __init__( self, path_to_file: str, ) -> None: - # ваш код - ... + self.path_to_file = path_to_file + self.file = None + self.orig_stdout = None - # ваш код + def __enter__(self): + self.orig_stdout = sys.stdout + self.file = open(self.path_to_file, "w") + sys.stdout = self.file + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + sys.stdout = self.orig_stdout + if self.file: + self.file.close() + return False From 3f7bba140bfe3383dba6eb9f6bbe2826a4cad0a0 Mon Sep 17 00:00:00 2001 From: korolinakila <112556625+korolinakila@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:52:21 +0300 Subject: [PATCH 13/17] Update task1.py --- solutions/sem02/lesson03/task1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solutions/sem02/lesson03/task1.py b/solutions/sem02/lesson03/task1.py index 69c5b6fae..99b5315f5 100644 --- a/solutions/sem02/lesson03/task1.py +++ b/solutions/sem02/lesson03/task1.py @@ -6,7 +6,7 @@ class ShapeMismatchError(Exception): def sum_arrays_vectorized(lhs: np.ndarray, rhs: np.ndarray,) -> np.ndarray: - if lhs != rhs: + if lhs.shape != rhs.shape: raise ShapeMismatchError return lhs + rhs @@ -18,4 +18,4 @@ def compute_poly_vectorized(abscissa: np.ndarray,) -> np.ndarray: def get_mutual_l2_distances_vectorized(lhs: np.ndarray,rhs: np.ndarray,) -> np.ndarray: if lhs.shape[1] != rhs.shape[1]: raise ShapeMismatchError - return (np.sum((lhs[:, np.newaxis, :] - rhs[np.newaxis, :, :]) ** 2, axis=2)) ** 0.5 \ No newline at end of file + return (np.sum((lhs[:, np.newaxis, :] - rhs[np.newaxis, :, :]) ** 2, axis=2)) ** 0.5 From f9ae41a662f96e60b07a35f8bd9cbbdc81909c95 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Fri, 13 Mar 2026 23:06:17 +0300 Subject: [PATCH 14/17] lesson4 dz --- solutions/sem02/lesson04/task1.py | 53 ++++++++++++++++++++++++++----- solutions/sem02/lesson04/task2.py | 30 +++++++++++++++-- 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/solutions/sem02/lesson04/task1.py b/solutions/sem02/lesson04/task1.py index 1b5526c1f..bb0b80fb0 100644 --- a/solutions/sem02/lesson04/task1.py +++ b/solutions/sem02/lesson04/task1.py @@ -2,16 +2,53 @@ def pad_image(image: np.ndarray, pad_size: int) -> np.ndarray: - # ваш код - return image + if pad_size < 1: + raise ValueError + + if len(image.shape) == 2: + length, width = image.shape[0], image.shape[1] + new_image = np.zeros((length + pad_size*2, width + pad_size*2), dtype=image.dtype) + new_image[pad_size:pad_size + length, pad_size:pad_size + width] = image + else: + length, width, color = image.shape[0], image.shape[1], image.shape[2] + new_image = np.zeros((length + pad_size*2, width + pad_size*2, color), dtype=image.dtype) + new_image[pad_size:pad_size + length, pad_size:pad_size + width, :] = image -def blur_image( - image: np.ndarray, - kernel_size: int, -) -> np.ndarray: - # ваш код - return image + return new_image + + + + + + +def blur_image(image: np.ndarray, kernel_size: int,) -> np.ndarray: + if kernel_size < 1 or kernel_size % 2 == 0: + raise ValueError + + if len(image.shape) == 2: + pad_size = kernel_size // 2 + new_image = pad_image(image, pad_size) + length, width = image.shape[0], image.shape[1] + result = np.zeros((length, width), dtype=np.uint8) + + for i in range(length): + for j in range(width): + window = new_image[i:i + kernel_size, j:j + kernel_size] + result[i, j] = np.mean(window) + + else: + pad_size = kernel_size // 2 + new_image = pad_image(image, pad_size) + length, width, color = image.shape[0], image.shape[1], image.shape[2] + result = np.zeros((length, width, color), dtype=np.uint8) + + for i in range(length): + for j in range(width): + window = new_image[i:i + kernel_size, j:j + kernel_size, :] + result[i, j, :] = np.mean(window) + + return result if __name__ == "__main__": diff --git a/solutions/sem02/lesson04/task2.py b/solutions/sem02/lesson04/task2.py index be9a2288f..2b0e3a06b 100644 --- a/solutions/sem02/lesson04/task2.py +++ b/solutions/sem02/lesson04/task2.py @@ -5,6 +5,32 @@ def get_dominant_color_info( image: np.ndarray[np.uint8], threshold: int = 5, ) -> tuple[np.uint8, float]: - # ваш код + + if threshold < 1: + raise ValueError("threshold must be positive") - return 0, 0 + counts = np.zeros(256, dtype=np.int64) + for pixel in image.ravel(): + counts[pixel] += 1 + + max_pixels = 0 + best_color = 0 + + for current_color in range(256): + if counts[current_color] > 0: + left = max(0, current_color - (threshold - 1)) + right = min(255, current_color + (threshold - 1)) + cur_sum = np.sum(counts[left:right + 1]) + + if cur_sum > max_pixels: + max_pixels = cur_sum + best_color = current_color + + elif cur_sum == max_pixels: + if counts[current_color] > counts[best_color]: + best_color = current_color + + total_pixels = image.size + percent = (max_pixels / total_pixels) * 100 + + return np.uint8(best_color), float(percent) From cae656b0a7baee40b3c02506cc6fb13adc49038b Mon Sep 17 00:00:00 2001 From: korolinakila Date: Fri, 20 Mar 2026 22:50:10 +0300 Subject: [PATCH 15/17] dz lesson 3 --- solutions/sem02/lesson05/task1.py | 15 ++++++++++----- solutions/sem02/lesson05/task2.py | 17 ++++++++++++++--- solutions/sem02/lesson05/task3.py | 14 +++++++++----- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/solutions/sem02/lesson05/task1.py b/solutions/sem02/lesson05/task1.py index e9c7c3c56..16cd6c3fa 100644 --- a/solutions/sem02/lesson05/task1.py +++ b/solutions/sem02/lesson05/task1.py @@ -5,8 +5,13 @@ class ShapeMismatchError(Exception): pass -def can_satisfy_demand( - costs: np.ndarray, - resource_amounts: np.ndarray, - demand_expected: np.ndarray, -) -> bool: ... +def can_satisfy_demand(costs: np.ndarray,resource_amounts: np.ndarray,demand_expected: np.ndarray,) -> bool: + if costs.shape[0] != len(resource_amounts) or costs.shape[1] != len(demand_expected): + raise ShapeMismatchError + + required_resources = costs @ demand_expected + for i in range(len(required_resources)): + if required_resources[i] > resource_amounts[i]: + return False + return True + \ No newline at end of file diff --git a/solutions/sem02/lesson05/task2.py b/solutions/sem02/lesson05/task2.py index be1fb9d2b..4d21245de 100644 --- a/solutions/sem02/lesson05/task2.py +++ b/solutions/sem02/lesson05/task2.py @@ -6,6 +6,17 @@ class ShapeMismatchError(Exception): def get_projections_components( - matrix: np.ndarray, - vector: np.ndarray, -) -> tuple[np.ndarray | None, np.ndarray | None]: ... + matrix: np.ndarray,vector: np.ndarray,) -> tuple[np.ndarray | None, np.ndarray | None]: + mshape = matrix.shape + if not (mshape[0] == mshape[1] and mshape[0] == vector.size): + raise ShapeMismatchError + + det = np.linalg.det(matrix) + if abs(det) < 1e-10: + return (None, None) + + ort_proj, ort_cond = [], [] + for base in matrix: + ort_proj.append((base @ vector) * base / (np.linalg.norm(base) ** 2)) + ort_cond.append(vector - (base @ vector) * base / (np.linalg.norm(base) ** 2)) + return (np.array(ort_proj), np.array(ort_cond)) \ No newline at end of file diff --git a/solutions/sem02/lesson05/task3.py b/solutions/sem02/lesson05/task3.py index 0c66906cb..a60b1f2ed 100644 --- a/solutions/sem02/lesson05/task3.py +++ b/solutions/sem02/lesson05/task3.py @@ -5,8 +5,12 @@ class ShapeMismatchError(Exception): pass -def adaptive_filter( - Vs: np.ndarray, - Vj: np.ndarray, - diag_A: np.ndarray, -) -> np.ndarray: ... +def adaptive_filter(Vs: np.ndarray, Vj: np.ndarray, diag_A: np.ndarray) -> np.ndarray: + if not (Vs.shape[0] == Vj.shape[0] and Vj.shape[1] == diag_A.shape[0]): + raise ShapeMismatchError + + Vj_H = np.transpose(np.conj(Vj)) + A = np.diag(diag_A) + I_K = np.eye(diag_A.size) + + return Vs - (Vj @ np.linalg.inv(I_K + Vj_H @ Vj @ A) @ (Vj_H @ Vs)) From 589570417ae7c630876c9a570c7221d7e7107019 Mon Sep 17 00:00:00 2001 From: korolinakila Date: Fri, 10 Apr 2026 22:51:29 +0300 Subject: [PATCH 16/17] hw lesson7 --- solutions/sem02/lesson07/task1.py | 75 +++++++++++++++++++++++++++++-- solutions/sem02/lesson07/task2.py | 43 +++++++++++++++++- 2 files changed, 114 insertions(+), 4 deletions(-) diff --git a/solutions/sem02/lesson07/task1.py b/solutions/sem02/lesson07/task1.py index 3a505d89b..36941d0e2 100644 --- a/solutions/sem02/lesson07/task1.py +++ b/solutions/sem02/lesson07/task1.py @@ -13,8 +13,77 @@ def visualize_diagrams( ordinates: np.ndarray, diagram_type: Any, ) -> None: - # ваш код - pass + if abscissa.shape[0] != ordinates.shape[0]: + raise ShapeMismatchError + + if diagram_type not in ["hist", "box", "violin"]: + raise ValueError + + figure = plt.figure(figsize=(8, 8)) + grid = plt.GridSpec(4, 4, wspace=space, hspace=space) + + axis_scatter = figure.add_subplot(grid[0:-1, 1:]) + axis_hist_vert = figure.add_subplot(grid[0:-1, 0], sharey=axis_scatter) + axis_hist_hor = figure.add_subplot(grid[-1, 1:], sharex=axis_scatter) + + axis_scatter.scatter(abscissa, ordinates, color="cornflowerblue", alpha=0.5) + + if diagram_type == "box": + axis_hist_vert.boxplot( + ordinates, + patch_artist=True, + boxprops={"facecolor": "lightsteelblue"}, + medianprops={"color": "black"}, + ) + axis_hist_hor.boxplot( + abscissa, + vert=False, + patch_artist=True, + boxprops={"facecolor": "lightsteelblue"}, + medianprops={"color": "black"}, + ) + + elif diagram_type == "hist": + axis_hist_vert.hist( + ordinates, + orientation="horizontal", + bins=50, + color="cornflowerblue", + alpha=0.5, + density=True, + ) + axis_hist_hor.hist( + abscissa, + bins=50, + color="cornflowerblue", + alpha=0.5, + density=True, + ) + axis_hist_vert.invert_xaxis() + axis_hist_hor.invert_yaxis() + + elif diagram_type == "violin": + viol_vert = axis_hist_vert.violinplot(ordinates, showmedians=True) + for body in viol_vert["bodies"]: + body.set_facecolor("cornflowerblue") + body.set_edgecolor("blue") + for part in viol_vert: + if part != "bodies": + viol_vert[part].set_edgecolor("cornflowerblue") + + viol_hor = axis_hist_hor.violinplot(abscissa, vert=False, showmedians=True) + for body in viol_hor["bodies"]: + body.set_facecolor("cornflowerblue") + body.set_edgecolor("blue") + for part in viol_hor: + if part != "bodies": + viol_hor[part].set_edgecolor("cornflowerblue") + + axis_hist_hor.set_yticks([]) + axis_hist_vert.set_xticks([]) + + plt.show() + if __name__ == "__main__": @@ -24,5 +93,5 @@ def visualize_diagrams( abscissa, ordinates = np.random.multivariate_normal(mean, cov, size=1000).T - visualize_diagrams(abscissa, ordinates, "hist") + visualize_diagrams(abscissa, ordinates, "box") plt.show() diff --git a/solutions/sem02/lesson07/task2.py b/solutions/sem02/lesson07/task2.py index decd607ef..d8b8c8a0b 100644 --- a/solutions/sem02/lesson07/task2.py +++ b/solutions/sem02/lesson07/task2.py @@ -1 +1,42 @@ -# ваш код (используйте функции или классы для решения данной задачи) +import json +from pathlib import Path + +import matplotlib.pyplot as plt +import numpy as np + + +def get_counts(tier_list, stages_list): + arr = np.array(tier_list) + return np.array([np.sum(arr == stage) for stage in stages_list]) + + +def heart_task(): + plt.style.use("ggplot") + + with open("solutions\sem02\lesson07\data\medic_data.json") as file: + data = json.load(file) + + stages_list = ["I", "II", "III", "IV"] + before_count = get_counts(data["before"], stages_list) + after_count = get_counts(data["after"], stages_list) + + fig, ax = plt.subplots(figsize=(10, 7)) + x = np.arange(len(stages_list)) + width = 0.25 + + ax.bar(x - width / 2, before_count, width, label="before", color="lightcoral", edgecolor="darkred") + ax.bar(x + width / 2, after_count, width, label="after", color="cornflowerblue", edgecolor="darkblue") + + ax.set_title("Стадии митральной недостаточности") + ax.set_ylabel("Количество больных") + ax.set_xticks(x) + ax.set_xticklabels(stages_list) + ax.legend() + fig.tight_layout() + + plt.savefig("solutions/sem02/lesson07/data/result.png") + plt.show() + + +if __name__ == "__main__": + heart_task() \ No newline at end of file From dafa96e2bf53062e31c916f54072a51da649982f Mon Sep 17 00:00:00 2001 From: korolinakila Date: Fri, 17 Apr 2026 23:50:17 +0300 Subject: [PATCH 17/17] dz 8 --- solutions/sem02/lesson07/data/result.png | Bin 0 -> 20973 bytes solutions/sem02/lesson08/task1.py | 53 ++++++++++++++++++----- 2 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 solutions/sem02/lesson07/data/result.png diff --git a/solutions/sem02/lesson07/data/result.png b/solutions/sem02/lesson07/data/result.png new file mode 100644 index 0000000000000000000000000000000000000000..363e14cbaa6a5c62a147abed9fc2a7620b3b4419 GIT binary patch literal 20973 zcmeIa2UJvPw=Ig=N{fxOilRgl3P=zoXUu>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PqrWS zLj#(@PaSrBpH80mj{}xqWcRTuOsu91CY+2uOm)JQ`XpC4KQU788G#XzVdU=QG93f9 zFcdP`Njgx-qO^6ZPaCsFdw+$*7lE{G@Yl`x0-VN*3&$h=qfXe;ajpLHbYCAn8=k+|as zJnF^isne0+4E#b4c-)H`u>PHgES%^yXymuCqiy##}=pNC{!AJeuifyV9L?u z2eXKr4*~=KFd*heRV+Lg3eDxDmHUKU-+11iUYb+Mr(=k>1|HrPM#+xI=Hq+xa;2K8 z5#b|TjwW&*1VUp!qKgbgGWYjtZAWS3mbz0jh;O_I1S4l7Z6^Od47^OoqT+75PyK&4 f;60cy$YA!1Uu9liq7&d0nAFZ|oy$G*%gz4>R{mt1 literal 0 HcmV?d00001 diff --git a/solutions/sem02/lesson08/task1.py b/solutions/sem02/lesson08/task1.py index 89f88572f..202d095b2 100644 --- a/solutions/sem02/lesson08/task1.py +++ b/solutions/sem02/lesson08/task1.py @@ -7,17 +7,48 @@ from matplotlib.animation import FuncAnimation -def create_modulation_animation( - modulation, - fc, - num_frames, - plot_duration, - time_step=0.001, - animation_step=0.01, - save_path="" -) -> FuncAnimation: - # ваш код - return FuncAnimation() +def create_modulation_animation(modulation, fc, num_frames, plot_duration, time_step=0.001, animation_step=0.01,save_path="") -> FuncAnimation: + def signal(t, modulation, fc): + base_signal = np.sin(2 * np.pi * fc * t) + if modulation is None: + return base_signal + return modulation(t) * base_signal + + figure, axis = plt.subplots(figsize=(12, 6)) + num_points = int(plot_duration / time_step) + 1 + time_segment = np.linspace(0, plot_duration, num_points) + num_segment = signal(time_segment, modulation, fc) + line, *_ = axis.plot(time_segment, num_segment, c="crimson") + result_duration = (num_frames - 1) * animation_step + plot_duration + result_num_points = int(result_duration / time_step) + 1 + result_time = np.linspace(0, result_duration, result_num_points) + total_signal = signal(result_time, modulation, fc) + axis.set_xlim(0, plot_duration) + ymax = 1.2 * np.max(np.abs(total_signal)) + axis.set_ylim(-ymax, ymax) + + def update(frame_id): + start = frame_id * animation_step + end = start + plot_duration + start_index = int(start / time_step) + end_index = start_index + num_points + time_minisegment = result_time[start_index:end_index] + signal_minisegment = total_signal[start_index:end_index] + line.set_data(time_minisegment, signal_minisegment) + axis.set_xlim(start, end) + return (line,) + + animation = FuncAnimation( + figure, + update, + frames=num_frames, + interval=50, + blit=False, + ) + if save_path: + animation.save(save_path, writer="pillow", fps=24) + return animation + if __name__ == "__main__":