uga/README.md

48 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# uga
def symmetric_difference(a: list, b: list) -> list:
set_a = set(a)
set_b = set(b)
result = set_a.symmetric_difference(set_b)
return sorted(result)
или
def symmetric_difference(a: list, b: list) -> list:
return sorted(set(a).symmetric_difference(set(b)))
# Тесты
assert symmetric_difference([1, 2, 3], [2, 3, 4]) == [1, 4]
assert symmetric_difference([1, 1, 2], [2, 2, 3]) == [1, 3]
assert symmetric_difference([], [1, 2]) == [1, 2]
assert symmetric_difference([1, 2], []) == [1, 2]
assert symmetric_difference([1, 1], [1, 1]) == []
assert symmetric_difference([5, 6, 7], [7, 8, 9]) == [5, 6, 8, 9]
print("Все тесты пройдены!")
как проверит что все рапботает
def normalize_list(numbers: list) -> list:
if not numbers:
return []
min_val = min(numbers)
max_val = max(numbers)
if max_val == min_val:
return [0.0 for _ in numbers]
range_val = max_val - min_val
return [(x - min_val) / range_val for x in numbers]
# Тесты
assert normalize_list([1, 2, 3, 4, 5]) == [0.0, 0.25, 0.5, 0.75, 1.0]
assert normalize_list([10, 10, 10]) == [0.0, 0.0, 0.0]
assert normalize_list([0, 10]) == [0.0, 1.0]
assert normalize_list([]) == []
assert normalize_list([-5, 0, 5]) == [0.0, 0.5, 1.0]
print("Все тесты пройдены!")