You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, calculate_pattern('meets', 'weary') currently returns (0, 2, 1, 0, 0), however the correct pattern should be (0, 2, 0, 0, 0) since there is not a second e in the target word. One way to do this correctly is:
from collections import Counter
def calculate_pattern(guess, true):
'''Yield the pattern that Wordle would return if you guessed `guess` and the true word is `true`'''
yellows = Counter(true)
for x, y in zip(guess, true):
if x == y:
yield 2
elif yellows[x] > 0:
yield 1
else:
yield 0
yellows[x] -= 1
you just need to then call this as tuple(calculate_pattern(word, word2)).
The text was updated successfully, but these errors were encountered:
I think you need to do two passes in order to also catch corner cases like calculate_pattern('rower', 'goner'), which currently returns (1, 2, 0, 2, 2) instead of (0, 2, 0, 2, 2).
For example,
calculate_pattern('meets', 'weary')
currently returns(0, 2, 1, 0, 0)
, however the correct pattern should be(0, 2, 0, 0, 0)
since there is not a seconde
in the target word. One way to do this correctly is:you just need to then call this as
tuple(calculate_pattern(word, word2))
.The text was updated successfully, but these errors were encountered: