13
1
This question is heavily based off this question, but should pose a number of additional difficulties.
Your Task
You must write a program or function that, when receiving a string, prints out all possible anagrams of it. For the purpose of this question, an anagram is a string that contains the same character as the original string, but is not the original string. A subanagram is an anagram of a substring of an inputted string. Anagrams and subanagrams do not have to be or contain actual words.
Input
You may accept a string, which may be of any length > 0, by any standard input method. It may contain any ASCII characters.
Output
You may output all of the possible anagrams and subanagrams of the inputted string in any standard way. You must not output the same string twice, or output a string equal to the input.
Other Rules
Standard Loopholes are disallowed
Scoring
This is code-golf, least bytes wins.
Is the empty string a possible anagram? – Digital Trauma – 2017-06-12T01:20:42.120
Is outputting the original string/sustrings allowed? – CalculatorFeline – 2017-06-12T02:25:46.083
@CalculatorFeline "You must not output the same string twice, or output a string equal to the input." – Jonathan Allan – 2017-06-12T02:30:29.913
@DigitalTrauma, "You may accept a string, which may be of any length > 0, by any standard input method". (emphasis added) – Gryphon – 2017-06-12T10:41:26.067
4Some Test cases would be helpful – Mr. Xcoder – 2017-06-12T12:05:18.570
"an anagram is a string that contains the same character as the original string, but is not the original string": it's unclear to me whether it applies to subanagrams as well (in which case
AB
is not a valid subanagram ofABCD
, butBA
is). Could you please clarify? – Arnauld – 2017-06-12T12:20:06.360Should
tt
be an anagram oftest
? If yes, then quite some given solutions are not working. If not, then I guess thataa
shouldn't be an anagram ofaabb
and again some solutions are not working. Some examples to explain this would be helpful :) – Michiel uit het Broek – 2017-06-12T14:20:45.933No, tt is not an anagram or a subanagram of "test". However, I never specifically said you couldn't output additional strings, which was a mistake in the question. I just said you couldn't output the same string twice, which I don't think any answer is doing, or output the original string, which I also don't think any answer is doing. I would change the question to not allow substrings of the input, but it's too late now, as that would invalidate existing answers. – Gryphon – 2017-06-12T16:49:17.110