hdarwin

cstutoringcenter.com_Silly Strings

Jan 23rd, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import re
  2. from collections import Counter
  3. sum = 0
  4. for file in open('strings.txt'):
  5.     c = Counter()
  6.     strs = file.strip()
  7.     for y in strs:c[y] += 1
  8.     numberofvowels = c['a'] + c['e'] + c['i'] + c['o'] + c['u']
  9.     numberofdigits = c['0'] + c['1'] + c['2'] + c['3'] + c['4'] + c['5'] + c['6'] + c['7'] + c['8'] + c['9']
  10.     if(numberofvowels) % 2 != 0:continue
  11.     if(numberofdigits < 3):continue
  12.     if 'b' in strs or 'q' in strs:continue
  13.     flag = 0
  14.     for x in strs:
  15.         if re.findall('[^0-9a-zA-Z]', x) != []:flag+=1
  16.     if flag > 3:continue
  17.     sum += 1
  18. print sum
Advertisement
Add Comment
Please, Sign In to add comment