From 55705a796ae4a62e974cc82a008934446b8255a1 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Sun, 17 May 2026 17:10:02 +0200 Subject: [PATCH] Minimales en Julia --- src/Julia/004.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Julia/004.jl diff --git a/src/Julia/004.jl b/src/Julia/004.jl new file mode 100644 index 0000000..d8b8d3d --- /dev/null +++ b/src/Julia/004.jl @@ -0,0 +1,27 @@ +function minimales(lst) + res = Vector{Vector{Int}}() + for (index, canditate) in enumerate(lst) + canditate_set = Set(canditate) + + is_subset_of_another = any( + index != other_index && canditate_set <= Set(other) + for (other_index, other) in enumerate(lst) + ) + + if is_subset_of_another + continue + end + + if !any(canditate_set == Set(existing) for existing in res) + push!(res, canditate) + end + + end + return res +end + +check = [[1, 3], [2, 3, 1], [3, 2, 5]] +println(minimales(check)) # [[2, 3, 1], [3, 2, 5]] + +check = [[1, 3], [2, 3, 1], [3, 2, 5], [3, 1]] +println(minimales(check)) # [[2, 3, 1], [3, 2, 5]]