Skip to content

Instantly share code, notes, and snippets.

@wting
Created April 26, 2012 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wting/2495828 to your computer and use it in GitHub Desktop.
Save wting/2495828 to your computer and use it in GitHub Desktop.
codejam: alien language
#!/usr/bin/env python2
import re
_, lines, cases = map(int,raw_input().split())
words = []
for _ in xrange(lines):
words.append(raw_input())
for c in xrange(cases):
pattern = raw_input().replace('(','[').replace(')',']')
p = re.compile(pattern)
found = 0
for w in words:
if p.search(w) != None: found += 1
print 'Case #%i: %i' % (c+1,found)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment