Game of Thrones - I

  • + 1 comment

    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

    d = {c:s.count(c) for c in set(s)}
    if sum(map(lambda x: x%2, d.values())) > 1:
        return 'NO'
    return 'YES'