How to find most occurring combinations in a list of lists. Combinations length can be any.
So, sample data:
l = [['action','mystery','horror','thriller'],
['drama','romance'],
['comedy','drama','romance'],
['scifi','mystery','horror','thriller'],
['horror','mystery','thriller']]
Expected output:
'mystery','horror','thriller' - 3 times
'drama','romance' - 2 times
With the help of this post
, I was able to find out most occurring pairs(combination of 2), but how to extend it find combinations of any length.
EDIT: As per @CrazyChucky's comment:
Sample input:
l = [['action','mystery','horror','thriller'],
['drama','romance'],
['comedy','drama','romance'],
['scifi','mystery','horror','thriller'],
['horror','mystery','thriller'],
['mystery','horror']]
Expected output:
'mystery','horror' - 4 times
'mystery','horror','thriller' - 3 times
'drama','romance' - 2 times