Skip to content

Charge a losing rematch as a skipped letter [patch] - #100

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/rematch-penalty-89
Sep 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/rematch-penalty-89

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #89

What changed

In CalculateScoreCore, a subject character that re-matches the current best letter was charged unmatchedLetterPenalty only 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

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
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeated pattern letters are sometimes free: "aaaaaaaaaab" scores the same as an exact "ab" and outranks "abx"

2 participants