843. Guess the Word (Hard) - TengnanYao/daily_leetcode GitHub Wiki
# """
# This is Master's API interface.
# You should not implement it, or speculate about its implementation
# """
# class Master:
# def guess(self, word: str) -> int:
class Solution:
def findSecretWord(self, wordlist: List[str], master: 'Master') -> None:
arr = wordlist[ : ]
while arr:
h = {}
k = random.randint(0, len(arr) - 1)
for word in arr:
count = 0
for i in range(6):
count += word[i] == arr[k][i]
h[count] = h.get(count, []) + [word]
n = master.guess(arr[k])
if n == 6:
return
arr = h[n]