Created
January 29, 2013 02:36
-
-
Save rbrito/4661238 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import string | |
import re | |
INPUT_FILE = 'balanced_smileystxt.txt' | |
input = open(INPUT_FILE, 'r') | |
count = input.readline() | |
for i in range(int(count)): | |
balanced_characters = set(string.ascii_lowercase) | |
balanced_characters.add(' ') | |
line = input.readline().strip() | |
line = ''.join(c for c in line if c not in balanced_characters) | |
p = re.compile('\(?(:\)|:\(|:)*\)?') | |
m = p.match(line) | |
if m and (m.end() - m.start() == len(line)): | |
print('Case #%d: %s' % (i + 1, 'YES')) | |
else: | |
print('Case #%d: %s' % (i + 1, 'NO')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment