How to check the all possible combinations in array ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

How to check the all possible combinations in array ?

the array is 1 2 3 4 5 1 2 3 4 5 12 13 14 15 23 24 25 34 35 45 123 124 125 134 135 145 234 235 245 345 1234 1235 1245 1345 2345 12345 I want to check this all possible combinations what is the logic for the all possible combinations

22nd Apr 2017, 9:30 AM
<Tharun Kumar>
<Tharun Kumar> - avatar
6 Answers
+ 15
I do not understand. What combinations? Combinations between them?
22nd Apr 2017, 9:42 AM
Gami
Gami - avatar
+ 10
this will probably help you. combinations of max 20 chars string https://code.sololearn.com/cIzIY4CL3m37/?ref=app
28th Apr 2017, 7:47 PM
Umbe
Umbe - avatar
+ 6
all possible combinations without repeating the same element of array
22nd Apr 2017, 10:05 AM
<Tharun Kumar>
<Tharun Kumar> - avatar
0
In ruby there's the option to do: list = ['1','2','3','4','5'] list.combination(size).map(&:join) This will create all possible combinations of the characters given with a length equal to "size"
22nd Apr 2017, 9:41 AM
spcan
spcan - avatar
0
Yes. For 1, 2, 3 and size = 3 the output is 123, 231, 312, etc... until there are no more unrepeated strings
22nd Apr 2017, 9:44 AM
spcan
spcan - avatar