20
6
Super permutations
Input: A string
The program should loop through all lengths of the input (decrementing one each time), generate all combinations with replacement of the string, then make permutations out of the generated combinations, and display all of the strings.
They can be separated with anything (doesn't need to be a comma)
Example for the string 'abc':
a, b, c, aa, ab, ac, ba, bb, bc, ca, cb, cc
aaa, aab, aac, aba, abb, abc, aca, acb, acc
baa, bab, bac, bba, bbb, bbc, bca, bcb, bcc
caa, cab, cac, cba, cbb, cbc, cca, ccb, ccc
The values don't necessarily have to be sorted.
Avoid any standard loop holes.
6Can we also include the empty string as a length zero permutation? – Jo King – 2020-01-25T13:02:37.003
7Will the string contain duplicates? If so, do you need the output to be deduplicated? – Neil – 2020-01-25T16:31:39.567
1I tagged this code golf, because all the answers are assuming it is. – xnor – 2020-01-25T18:57:20.153
9
I'm finding the talk of permutations and combinations confusing here. The way I'd phrase the task is: output all strings made of characters in the input, whose length ranges from 1 to the length of the input. Related: Output all strings.
– xnor – 2020-01-25T18:59:59.8231Can we take a length argument? – S.S. Anne – 2020-01-26T14:09:39.887
Can we output a list of lists? Like
[[a,b], [aa,ab,ba,bb]]
? Some answers already assume this, while others flatten the list – Jo King – 2020-01-28T01:28:03.513