23 lines
682 B
Python
23 lines
682 B
Python
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]]
|