Skip to content

Instantly share code, notes, and snippets.

@ethernet8023
Created October 20, 2016 16:03
Show Gist options
  • Select an option

  • Save ethernet8023/41154e6decaab2cd937db5ba65ef918d to your computer and use it in GitHub Desktop.

Select an option

Save ethernet8023/41154e6decaab2cd937db5ba65ef918d to your computer and use it in GitHub Desktop.
def doThing(dic, words):
charsNeeded = [doesIntersect(dic, word) for word in words]
A1 = "Yes" if all(charsNeeded) else "No"
A2 = max(*charsNeeded)
return A1 + " " + str(A2)
def doesIntersect(dic, word):
dic = list(dic)
charsNeeded = 0
for char in word:
if char in dic:
dic.remove(char)
else:
charsNeeded += 1
return True if charsNeeded == 0 else charsNeeded
num_cases = int(input())
for i in range(num_cases):
num_words, num_strings = [int(x) for x in input().split(' ')]
words = [input() for _ in range(num_words)]
strings = [input() for _ in range(num_strings)]
validatedStrings = [doThing(st, words) for st in strings]
[print(st) for st in validatedStrings]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment