2
def getHint(self, secret: str, guess: str) -> str:4
# Setup counts for bulls and cows7
# Copy secret and guess into lists that are easier to work with8
secretCopy = list(secret)9
guessCopy = list(guess)11
# In a for loop, check every pair of letters at the same index in both guess and secret for matching letters, AKA bulls12
for i in range(len(secret)):14
# If they match, bulls += 1 and pop() the letters from the copy lists via their .index()15
if secret[i] == guess[i]:17
secretCopy.pop(secretCopy.index(secret[i]))18
guessCopy.pop(guessCopy.index(guess[i]))20
# Count() the letters remaining in secret and guess lists21
secretCounter = Counter(secretCopy)22
guessCounter = Counter(guessCopy)24
# Counter1 - Counter2 gives us Counter1 with any matching values of Counter1 and Counter2 removed; leftover Counter2 values are trashed25
# secretCounter - guessCounter gives us the secretCounter except for any correctly guessed letters26
# Therefore, subtract this difference from the OG secretCounter to be left with a counter of only correctly guessed letters27
dif = secretCounter - (secretCounter - guessCounter)29
# The .total() of the dif Counter is the number of cows32
# return the formatted string with req. info33
return f"{bulls}A{cows}B"