I searched over the internet a lot how to do this but I didn't came up with something I completely understood.
Im trying to generate all the possible combinations from an array of letters by specifying the amount of letters in each group, for example:
letters: A, B, C
length: 2
result: AB, AC, BC
(I know there are: BA
, CA
and CB
too but I only need to get the groups the order isn't matter.)
example 2:
letters: A, B, C, D
length: 3
result: ABC, ACD, BCD, CDA, DAB
and etc…
I intend to implement that algorithm in C++ but examples in C#, Java or Javascript are welcome as well.