1
$\begingroup$

Lets say A is an ordered list contains of elements [a,a,b,a,c]. I want to get all combinations of elements by sequential order like (a,a) (a,b) (b,a) (b,c). But (c,a) or (c,b) cannot be part of this. Is there any easy method to formulate this ? Also I want to keep count of every combination occurrence. For example:

(a,a) - 3 times
(a,b) - 2 times 

etc.

0 Answers 0