Answer the question
In order to leave comments, you need to log in
Combinatorics in Java Script, how to add a dot in all possible combinations of an array?
you need to make sure that when you enter a string, a dot is put in all possible combinations, including two dots
Answer the question
In order to leave comments, you need to log in
Make a recursive function that solves your problem. If the character at the input is 1 - just return it. If there are several input characters, then it bites off the last character and is called recursively, then appends the last character and the point-last character (a new array with twice the number of elements) to each element of the returned array.
So for 3 characters "abc" the function for "ab" will be called, which will return [ab, ab], adding "c" and ".c" to each element we get [abc, ab.c, a.bc, abc] .
Concatenation (thinning) with a bit "mask".
ABC - string
M1, M2 - two-bit "mask"
Glue in a loop: A+M1+B+M2+C
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question