diff --git a/src/Python/004.py b/src/Python/004.py new file mode 100644 index 0000000..38bff64 --- /dev/null +++ b/src/Python/004.py @@ -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]]