DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Christian has posted 1 posts at DZone. View Full User Profile

Google Code Jam Alien Language Solution

  • submit to reddit
        // Complete description of the problem and the code can found

import sys, re
fp = file(sys.argv[1])
#read params
(l, d, n) = [int(x) for x in]
#read words
words = [ for x in range(d)]
#read pattern
for i in range(1, n+1):
    searchStr ="(","[").replace(")","]")
    searchIt = re.compile(searchStr).search
    print "Case #%d: %d" % (i, len(filter(searchIt, words)))