Skip to content

Instantly share code, notes, and snippets.

@arthurnn
Created January 23, 2012 23:26
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 arthurnn/1666350 to your computer and use it in GitHub Desktop.
Save arthurnn/1666350 to your computer and use it in GitHub Desktop.
Alphabet Soup solution for Facebook HackerCup
#!/usr/bin/env python
# encoding: utf-8
"""
Created by @arthurnn
"""
import sys
import os
import fileinput
def main():
f = fileinput.input()
next(f)
for i,line in enumerate(f):
#print line
hash = {}
for l in line:
v = hash.setdefault(l,0)
hash[l] = v+1
#print hash
try:
# 2 'C' in the main word
hash['C'] = hash['C'] / 2
abc = [hash[v] for v in "HACKERCUP"]
except:
print "Case #%d: 0" % (i+1)
print "Case #%d: %d" % ((i+1),min(abc))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment