3 ms·
Here's a variant of the last solution the author presented, using a Counter of each word, instead a sorted list of words' chars, as normalization. cnt=Counte
by father_of_two 11y ago
Here's a variant of the last solution the author presented, using a Counter of each word, instead a sorted list of words' chars, as normalization.
cnt=Counter(tuple(Counter(w).iteritems()) for w in words)
print [w for w in words if cnt[tuple(Counter(w).iteritems())] > 1]
This is just code golfing, I don't even think it's clear. The last solution of the author is nice, though.
- gamesbrainiac 11y agoThis is actually quite nice. A little hard to see, but I see what you did there. You'd get an earful from the algorithm-nazis though ;)