28
3
Given a list of unique strings that are anagrams of each other, output an anagram of those words that is different from each word in the list.
The strings will be alphanumeric, and there is guaranteed to be a valid anagram.
The program or function can, but doesn't have to be non-deterministic, meaning given the same input, multiple running a of the code can yield different outputs, as long as every possible output is a valid one.
Test Cases
[Input] -> Possible output
-----------------
[ab] -> ba
[aba, aab] -> baa
[123, 132, 231, 312, 321] -> 213
[hq999, 9h9q9, 9qh99] -> 999hq
[abcde123, ab3e1cd2, 321edbac, bcda1e23] -> ba213ecd
4But is
itertools
ever the answer? – MildlyMilquetoast – 2017-11-14T06:44:07.353@MistahFiggins Nominated
– Mr. Xcoder – 2017-11-14T09:46:02.523@Mr.Xcoder before 22 July 2015 – Stan Strum – 2017-11-14T15:24:20.377
@StanStrum I just mentioned it, I am aware of that restriction. As Stewie said...
– Mr. Xcoder – 2017-11-14T15:25:09.230@Mr.Xcoder didn’t see that, cool! – Stan Strum – 2017-11-14T15:25:52.853
If there a reason the import is after the lambda? – jpmc26 – 2017-11-14T21:26:00.940
1@jpmc26 Yes, this way you can put
f=\
in the Try it Online header and leave the function anonymous, while not affecting the automatic TiO byte counter – Mr. Xcoder – 2017-11-14T21:27:06.517Nifty. Thanks for answering. – jpmc26 – 2017-11-14T21:37:28.170
Great submission. I'd be interested to know if there's a shorter non-itertools solution. random string generation or
sort
with a random key would all be longer than your code. – Eric Duminil – 2017-11-15T12:33:31.063