Using python I would like to calculate all combinations of 3 from a list.
For example, list = [a,b,c,d] and combinations would be – [a,b,c], [a,b,d], [a,c,d], [b,c,d].
And then I would like to add some items to the original list and get only the additional combinations of 3.
For example, adding items [e,f] would generate new combinations – [a,b,e], [a,b,f], [a,c,e], [a,c,f], [a,d,e], [a,d,f], [a,e,f], [b,c,e], [b,c,f],…
The lists will be large so we need to avoid generating the combinations twice and then filtering in order to get the ‘additional combinations’.
Background:
I use itertools.combinations to get all combinations (of 3) for a list right now of about 100 items. That generates a lot of combinations and I doing a bunch of calculations and whatnot based on those combinations, looking for patterns and matches and stuff. I get through all that processing and if I don’t have a ‘successful’ combination of 3 then I generate more candidates for the list (which in itself takes a long time). When I add the additional candidates to the list (usually like 10 or so), I then restart the analysis on the combinations which seems wasteful, so I would like to only be checking the ‘additional’ combinations.