I am trying to generate all possible combinations of array of characters. Input array contains n characters, 5 & lt; = N & lt; = 7, and I would like to generate a second array A (C, N, 5), 5, which contains all C (N, 5) combinations. The order of letters in the array is not important.
Here is an example: Input array: {A, B, C, D, E, F}, therefore n = 6 should be output array:
{ABCDE }, {ABCDF}, {ABCFE}, {ABFDE}, {AFCDE}, {FBCDE},
It is very easy for N = 5 and n = 6, but n = 7 becomes very complicated for. Does anyone know how I should do this?
Thanks
repeat this regularly
for example , Your n = 7 case in the outer layer, you start with {A, B, C, D, E, F, G}. From this, you take a letter; You have 7 elements in 7 output orange sets in a different one 7 times (A, B, C, D, E, F), {A, B, C, D, E, G} etc. Each: 6 characters with.
For these outputs each , you reduce the use of the same algorithm after it. You already know how to deal with {A, B, C, D, E, F}.
No comments:
Post a Comment