Created
December 1, 2015 23:49
-
-
Save erdem/4df82f4371b7714247aa to your computer and use it in GitHub Desktop.
Codingame MIME Type puzzle solution
This file contains 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
import sys | |
import math | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
n = int(raw_input()) # Number of elements which make up the association table. | |
q = int(raw_input()) # Number Q of file names to be analyzed. | |
mime_type_map = {} | |
for i in xrange(n): | |
# ext: file extension | |
# mt: MIME type. | |
ext, mt = raw_input().split() | |
mime_type_map[ext.lower()]=mt | |
for i in xrange(q): | |
fname = raw_input() # One file name per line | |
if not "." in fname: | |
print "UNKNOWN" | |
continue | |
f_ext = fname.split(".")[-1].lower() | |
if mime_type_map.get(f_ext): | |
print mime_type_map[f_ext] | |
else: | |
print "UNKNOWN" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment