Back to problems
COMP2041
22T2 Q10 — equi-group (anagram grouping)
Read whitespace-separated words from stdin. Group words having the same multiset of characters (anagrams). Output groups ordered by size descending, ties broken by the group's sorted word list. Each line: the group size followed by its words in lexicographic order, space-separated.
$ echo eat tea ate bat tab cat | ./prog 3 ate eat tea 2 bat tab 1 cat
Python only. From COMP2041/9044 22T2 Final.
Samples
stdin
eat tea ate bat tab cat
expected
3 ate eat tea 2 bat tab 1 cat
python3
14