I have a problem that I could not find a good answer for: I want to merge two lists but keep the same number of occurrences from each object EX:
list1 = [2,3,7]
list2 = [2,2,5]
After merging thees two lists the result should look like this:
res = [2,2,3,5,7] #it does not need to be sorted
Observe that from the beginning there was together three "2" but after merging there should only be two "2"
The closest I have found is in this post: Combining two lists and removing duplicates, without removing duplicates in original list
but this does not work the way I want it.
an other example:
l1 = [2]
l2 = [3]
l3 = [2,2]
l4 = [5]
l5 = [2,3]
#after adding all the lists above
result = [2,2,3,5]