Created
October 11, 2015 17:58
-
-
Save jdiez17/1e09a60c93df6bc799a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
chars = sorted(sys.stdin.read())[1:] | |
histogram = {} | |
for c in chars: | |
if c in histogram: | |
histogram[c] += 1 | |
else: | |
histogram[c] = 1 | |
flag = True | |
odd, even = 0, 0 | |
for char, count in histogram.items(): | |
if count % 2 != 0: | |
odd += 1 | |
else: | |
even +=1 | |
if len(chars) % 2 == 0: | |
# check there is an even number of every character | |
flag = odd == 0 | |
else: | |
if odd == 1: | |
flag = True | |
else: | |
flag = False | |
print("YES" if flag else "NO") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment