DEV Community

Discussion on: Solution: Word Subsets

Collapse
 
seanpgallivan profile image
seanpgallivan

Unfortunately, that doesn't account for multiple occurrences of the same letter.

The instructions state:

Now, say that word b is a subset of word a if every letter in b occurs in a, including multiplicity. For example, "wrr" is a subset of "warrior", but is not a subset of "world".

The code you posted would find "wrr" as a subset of "world", because the set will only compare a single "r" instead of requiring 2 for a match.

It's still a remarkable piece of code, however! One of the things that impresses (and intimidates) me the most about Python is its ability to allow for truly concise code.