Charge a losing rematch as a skipped letter [patch] - #100
Merged
Merged
Conversation
A subject character that re-matched the current best letter was charged only when it scored at least as well. A losing rematch cost nothing, so repeats of a well-scoring letter were free: "aaaaaaaaaab" tied an exact "ab" and outranked "abx". Fixes #89 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014jNTPLxThrQnZyafw1CZ1p
|
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #89
What changed
In
CalculateScoreCore, a subject character that re-matches the current best letter was chargedunmatchedLetterPenaltyonly when it scored at least as well as that letter. When it scored lower, it cost nothing. Repeats of a letter that had earned a big bonus were therefore free:"aaaaaaaaaab"tied an exact"ab"(15) and outranked"abx"(14).A losing rematch is now charged the same penalty as any other skipped letter.
Tests
Three ordering regression tests from the issue:
Score("ab","ab") > Score("aab","ab")Score("abx","ab") > Score("aaaaaaaaaab","ab")Score("a_b","ab") > Score("a_bbbbbbbbbb","ab")All three failed on
main(15 vs 15, 14 vs 15, 19 vs 19) and pass with the fix. The full suite passes: 65 of 65.Downstream consumers such as TextFilter may see small ranking changes for subjects with repeated letters.
🤖 Generated with Claude Code
https://claude.ai/code/session_014jNTPLxThrQnZyafw1CZ1p
Generated by Claude Code