Loading...
Loading...
Loading...
Group the n given words so that words made from the same letters are together. Print one group per line, with the words separated by spaces. Words inside a group keep their input order, and groups appear in the order of their first word.
Example
Input
6 eat tea tan ate nat bat
Output
eat tea ate tan nat bat
Three groups.
Try the problem first. Open one hint at a time.
Words that are anagrams have the same letters when sorted.
Use the sorted letters as a dictionary key. A dict keeps insertion order.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor