You are viewing a single comment's thread. Return to all comments →
from collections import Counter
print "YES" if len(filter(lambda x: x & 1, Counter(raw_input()).values())) <= 1 else "NO"
s = input().strip()
if len([c for c in set(s) if s.count(c) % 2 != 0]) < 2:
you use set(s) in the loop, so it is unnessary work
Is it evaluated every
Sure (has not), my bad
one line, can you golf it more? ;)
return (sum(s.count(x)%2 for x in set(s) ) <2 and 'YES') or 'NO'
Without using sets (and in Haskell, not Python):
isAnaPalin = bool "YES" "NO" . (>1) . length . filter id . map (odd . length) . group . sort
I'm sure it's possible to do a lot better than that though.