Skip to content

Instantly share code, notes, and snippets.

@sjparkinson
Created October 17, 2016 12:45
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 sjparkinson/01a59c332ee09a417b7917ad28313fa9 to your computer and use it in GitHub Desktop.
Save sjparkinson/01a59c332ee09a417b7917ad28313fa9 to your computer and use it in GitHub Desktop.
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
mime_types = {}
file_names = []
count_mime_types = int(input()) # Number of elements which make up the association table.
count_file_names = int(input()) # Number of file names to be analyzed.
for i in range(count_mime_types):
extension, value = input().split()
mime_types[extension.lower()] = value
for i in range(count_file_names):
file_name = input()
# There may not be an extension...
if "." in file_name:
# Second value is the extension.
file_extension = file_name.rsplit(".", 1)[1].lower()
# Lookup with a default value.
print(mime_types.get(file_extension, "UNKNOWN"))
else:
print("UNKNOWN")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment