Skip to content

Instantly share code, notes, and snippets.

@ZengetsuFR
Created June 3, 2015 07:15
Show Gist options
  • Save ZengetsuFR/18d7de41053e04e3a33c to your computer and use it in GitHub Desktop.
Save ZengetsuFR/18d7de41053e04e3a33c to your computer and use it in GitHub Desktop.
Résolution du jeu "MIME Type" sur le site codingame.com
import sys, math,re
# 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.
d ={}
#dico avec extension en cle et le type mime pour valeur
for i in xrange(N):
EXT, MT = raw_input().split()
if len(EXT)<=10 and len(MT)<=50:
d[EXT.lower()]=MT
for l in xrange(Q):
FNAME = raw_input() # One file name per line.
#Expression reguliere pour verifier qu'il
m = re.search(r"\.[0-9A-Za-z]{1,10}$",FNAME.lower())
v = "UNKNOWN"
if m != None:
try:
#on utilise m comme cle pour le dico d
#doit retourner le type mime si la cle existe
v = d[FNAME.lower()[m.start()+1:]]
except:
v="UNKNOWN"
print v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment