Minimales en Julia

This commit is contained in:
2026-05-17 17:10:02 +02:00
parent aa176f7038
commit 55705a796a

27
src/Julia/004.jl Normal file
View File

@@ -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]]