You are viewing a single comment's thread. Return to all comments →
Use dictionary comprehension and s.count()
s.count()
Map modulo two across the counts, odd = 1, even = 0, summing the result
If there is more than one odd result cannot be a palindrome
d = {c:s.count(c) for c in set(s)} if sum(map(lambda x: x%2, d.values())) > 1: return 'NO' return 'YES'
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
Use dictionary comprehension and
s.count()
Map modulo two across the counts, odd = 1, even = 0, summing the result
If there is more than one odd result cannot be a palindrome