From aa176f70386e1a528d0b5d5381636d4acf0f0a63 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Sun, 17 May 2026 17:09:45 +0200 Subject: [PATCH] Minimales en Python --- src/Python/004.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/Python/004.py 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]]