Skip to content

Instantly share code, notes, and snippets.

@ferreiro
Created September 30, 2016 00:11
Show Gist options
  • Save ferreiro/ea852971748d219f80862914653879d3 to your computer and use it in GitHub Desktop.
Save ferreiro/ea852971748d219f80862914653879d3 to your computer and use it in GitHub Desktop.
import sys
elements = []
total_cases = int(input())
for i in range(0, total_cases):
db_size = int(input())
for j in range(0, db_size):
entry = str(input())
entry = entry.split(' ')
elements.append({
'name': entry[0],
'low': int(entry[1]),
'high': int(entry[2])
})
result = []
total_queries = int(input())
for j in range(0, total_queries):
query = int(input())
query_result = list(filter(lambda x: int(query) in range(x['low'], x['high']), elements))
if len(query_result) == 1:
result.append(query_result[0]['name'])
else:
result.append('UNDETERMINED')
solution = ''
for r in result:
solution += r
solution += '\n'
print(solution)
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment