Objective
Sets cannot be used as dictionary keys, but frozenset (immutable sets) can. They serve to group by “which letters appear”, regardless of order or repetitions.
Instructions
- The first line has the number
nof words; then one per line (lowercase, letters only). - Group the words that have the same set of distinct letters (for example
abbaandbaab). Show one group per line with its words without repeats and sorted alphabetically, separated by a space, and the groups sorted.
6
listen
silent
abba
ab
baab
enlist
ab abba baab
enlist listen silent
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise