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