Loading...
Loading...
Loading...
Words that use the same letters belong in one group. Group the words. Print one line per group with its words in input order, and list the groups in the order of their first word.
Example
Input
6 listen silent enlist google gogole cat
Output
listen silent enlist google gogole cat
Three groups.
Try the problem first. Open one hint at a time.
Sort the letters of a word. Anagrams give the same sorted text.
Use the sorted text as a dictionary key; a dictionary keeps the order in which keys first appear.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor