Anagrams
(Medium Problem)
Given an English text print out the list of words and their anagrams
in their order of occurrence. Word A is an anagram of word B if it can
be derived from word B by merely shuffling the letters in word B.
Important Points:
•Text can contain words in upper case as well as lower case and
punctuation marks
•Anagrams are not to be case sensitive
•The word and its anagrams are to be printed in the order of their
occurrence in the text, separated by a blank.
•If a word has no anagram in the text, then do not print it
•If a word or its anagram occurs more than once do not print it again
•Numbers are to be considered as valid words
Input:
•A text containing K English words (where K <= 5000), with spaces and
punctuation marks
Output:
•The output should contain the word (in its order of occurrence in
the text) and its set of anagrams in the text (again in their order of
occurrence), separated by blanks
•Each new list of words and anagrams should begin on a new line
•All words in the output should be printed in lower case characters
Sample Input    
Parts of the world have sunlight for close to 24 hours during summer.
Dan went to the north pole to lead an expedition during summer. He had
a strap on his head to identify himself as the leader. Dan had to deal
with the sun never going down for 42 consecutive days and his
leadership strap soon became a blindfold. He wondered what kind of
traps lay ahead of him.
Sample Output
parts strap traps
24 42
dan and
lead deal

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAKX5ECPbG2AFs2n%2BjiU4zVxamLXM_acPDxCWR16nmGTk5nOyEw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to