Minimales en Python

This commit is contained in:
2026-05-17 17:09:45 +02:00
parent aa20952dc2
commit aa176f7038

22
src/Python/004.py Normal file
View File

@@ -0,0 +1,22 @@
def minimales(lst: list[list[int]]) -> list[list[int]]:
res = []
for index, candidate in enumerate(lst):
candidate_set = set(candidate)
is_subset_of_another = any(
index != other_index and candidate_set <= set(other)
for other_index, other in enumerate(lst)
)
if is_subset_of_another:
continue
if not any(candidate_set == set(existing) for existing in res):
res.append(candidate)
return res
check = [[1, 3], [2, 3, 1], [3, 2, 5]]
print(minimales(check)) # [[2, 3, 1], [3, 2, 5]]
check = [[1, 3], [2, 3, 1], [3, 2, 5], [3, 1]]
print(minimales(check)) # [[2, 3, 1], [3, 2, 5]]