I work in Python. The dictionary that I have is as follows:
score = {'a':{4:'c', 3:'d'}, 'b':{6:'c', 3:'d'}}
And I need to order it like this:
rank = [{a:3, b:6}, {a:4, b:3}]
If the sub-dictionary with the largest combination of exclusive key values ββis in the first element, the second largest combination of exclusive key values ββis in the second element, and so on. The biggest combinational logic: 1. Take the largest combination (total amount) of keys from each dictionary (in this case it will be β 4: 'c' and b-> 6: 'd'. Remove these values ββfrom the dictionary and take the next a large key combination (in this case it will be a-> 4: 'c' and b-> 3: 'd'). This should continue until the original dictionary becomes empty.
This is exclusive, because once a value has been used from the original dict, it should be removed or excluded from use again in any future combinations.
I tried all the different approaches that I know, but algorithmically I am missing something.
source share