lang_tools.exercises.wordle
¶
Wordle exercise (from worldly-words).
Guess a hidden word within word_length + 1 attempts. After each guess,
each letter receives a state: correct (right letter, right position),
misplaced (right letter, wrong position), or wrong. Comparison is done
on accent-stripped (normalized) forms.
Classes:
-
LetterResult–Per-letter evaluation of a guess.
-
WordleExercise–Wordle round factory.
LetterResult
¶
Bases: BaseModel
Per-letter evaluation of a guess.
Attributes:
-
letter(str) –The character (in the guess form, accent-stripped).
-
state(LetterState) –One of
"correct","misplaced","wrong".
WordleExercise
dataclass
¶
Bases: _BaseExercise
Wordle round factory.
Initialize the exercise.
Parameters:
-
**kwargs(object, default:{}) –Forwarded to
_BaseExercise.
Methods:
Source code in src/lang_tools/exercises/wordle.py
start
¶
Build a Wordle round around target.
Parameters:
-
target(Word) –The hidden word.
-
max_attempts(int | None, default:None) –Override for the default
len(target) + 1.
Returns:
-
ExerciseRound–ExerciseRoundwhoseexpectedis the internal_WordleState.
Source code in src/lang_tools/exercises/wordle.py
submit
¶
Evaluate a single guess.
Parameters:
-
round_(ExerciseRound) –The round returned by
start. -
guess(str) –User's guess. Compared against the normalized target.
Returns:
-
RoundResult–RoundResultflagging this guess. When the round terminates (win -
RoundResult–or attempts exhausted) a
WordResultis appended.