I have four letters with different weights as
letters = ['C', 'N', 'O', 'S']
weights_of_l = [1, 1, 2, 2]
I want to get the combinations of letters which weight = 2
. The letter can be repeatedly chose and order is not important. The result can be list or array or any forms but with this combinations
comb_w2 = ['CC','NN','NC','O','S']
Here C
and N
has weight = 1
so combining two letters have weight = 2
: The possible combinations are 'CC','NN','NC'
O
and S
has weight = 2
already so it cannot combine with other letters. Is there any libraries for calculating this? I saw itertools
but it gives only the number of possibility, not the combinations.