Warning: Wouldn't you rather answer a challenge about ponies?1
If you have read The Hostile Hospital, you would know that the Baudelaire orphans, from one of the scraps of paper recovered from the Quagmire's notebooks, they discover a name, "Ana Gram". Later on, they realize that means the word "anagram", not a name. And that information helps them in finding out who Count Olaf disguised Violet Baudelaire as (Laura V. Bleediotie). They have to search through the entire hospital list, but trace the correct person down. However, what if they lived in a time where YOU helped them? Not personally, but with a program?
So your task today is simple. Given a string a
and an array, return a smaller array that contains all the possible anagrams of a
.
Rules:
- This is code-golf, so shortest answer wins
- Make sure to lowercase everything in the array and the string
- Two strings that are the same are not anagrams after normalizing
- Make sure to watch out for initials! You should also remove them
- There may be multiple possible anagrams. Output them all
Test cases:
String, Array
-> Array
"Violet", ["Veilo","Efh", "Telvio","veliot"]
-> ["Telvio","veliot"]
"Krotasmon", ["Krotas Mon","Krota","Monsakrot", "Trokasmont","KROTASMON"]
-> ["Monsakrot"]
"Laura V. Bleediotie", ["Violet Baudelaire", "Violet. Baudelaire", "VIOLeT BAUDELAIRE", "BUADELIAR VIOLETM", "Laura V. Bleediotie"]
-> ["Violet Baudelaire", "Violet. Baudelaire", "VIOLeT BAUDELAIRE"]
1: Inspired by the "all rights reserved" page of LS: The Unauthorized Autobiography
Krotas Mon
is not an anagram ofKrotasmon
. \$\endgroup\$