import sys
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
test=test.split(" | ")
word=test[1]
word_char=[0]*26
for x in word.lower():
if x.isalpha():
word_char[ord(x)-ord('a')] += 1
wine_list=test[0].split()
sol_list=[]
for wine in wine_list:
wine_chars=[0]*26
for x in wine.lower():
if x.isalpha():
wine_chars[ord(x)-ord('a')] += 1
listed=True
for i in range(len(wine_chars)):
if wine_chars[i] < word_char[i]:
listed=False
break
if listed:
sol_list.append(wine)
sol=""
for i in range(len(sol_list)):
if i>0 :
sol += " "
sol += sol_list[i]
if sol:
print sol
else:
print False
test_cases.close()
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
test=test.split(" | ")
word=test[1]
word_char=[0]*26
for x in word.lower():
if x.isalpha():
word_char[ord(x)-ord('a')] += 1
wine_list=test[0].split()
sol_list=[]
for wine in wine_list:
wine_chars=[0]*26
for x in wine.lower():
if x.isalpha():
wine_chars[ord(x)-ord('a')] += 1
listed=True
for i in range(len(wine_chars)):
if wine_chars[i] < word_char[i]:
listed=False
break
if listed:
sol_list.append(wine)
sol=""
for i in range(len(sol_list)):
if i>0 :
sol += " "
sol += sol_list[i]
if sol:
print sol
else:
print False
test_cases.close()
No comments:
Post a Comment