Given a list of strings and a length, give all combinations of that list with the given length. The problem is: your code must not be recursive. Yes, it can be done. I have done it myself, when I had no clue what this "recursion" was.
Input: A list of strings of an undefined length, and an integer defining the length of the combination. The strings will be at least one character long, and will only contain letters or numbers. The way of input will be specified by you, the programmer.
Output: A list of possible combinations as strings, not necessarily distinct (although you can make it that way, if you like). You do not have to sort the list.
Test Cases:
As said before, the method of input will be specified by you.
[a,b] 3 -> Nothing
[1,0,0] 2 -> 10 10 00
, or 00 10
if distinct.
[abc,bcd,cde] 2 -> abcbcd abccde bcdcde
If you even manage to do this, I will commend you. As always, shortest code wins. Good luck.
cdeabc
a valid combination? \$\endgroup\$