Open the context
Choose the project folder and name the files or behavior involved.
Score a five-letter lowercase ASCII guess with 2 for exact, 1 for misplaced and 0 for absent letters. Test repeated letters after reserving exact matches, rejecting uppercase, non-ASCII or wrong-length words.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
from collections import Counter
def letter_feedback(answer, guess):
if any(type(s) is not str or len(s) != 5 or any(not "a" <= c <= "z" for c in s) for s in (answer, guess)):
raise ValueError("word.lowercase")
marks, remaining = [0] * 5, Counter()
for i, (a, g) in enumerate(zip(answer, guess)):
if a == g:
marks[i] = 2
else:
remaining[a] += 1
for i, g in enumerate(guess):
if marks[i] != 2 and remaining[g]:
marks[i] = 1
remaining[g] -= 1
return marksThe example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.