feat: add --exclude flag to filter out words with specific letters

Added --exclude argument to allow users to exclude words containing any
of the specified letters. This is useful for Wordle gameplay when certain
letters have been ruled out.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-04 09:00:21 -05:00
parent 347a4cbe5a
commit bab9521522

View File

@@ -17,6 +17,11 @@ def main() -> int:
metavar="LETTERS",
help="Only include words composed solely of these letters (case-insensitive)",
)
parser.add_argument(
"--exclude",
metavar="LETTERS",
help="Exclude words containing any of these letters (case-insensitive)",
)
parser.add_argument(
"--mask",
metavar="PATTERN",
@@ -44,6 +49,7 @@ def main() -> int:
args = parser.parse_args()
only_set = set(args.only.lower()) if args.only else None
exclude_set = set(args.exclude.lower()) if args.exclude else None
# Prepare matchers
# Validate and normalize mask
@@ -82,6 +88,8 @@ def main() -> int:
def matches(word: str) -> bool:
if only_set is not None and not (set(word.lower()) <= only_set):
return False
if exclude_set is not None and (set(word.lower()) & exclude_set):
return False
if mask_positions is not None:
wl = word.lower()
for i, ch in enumerate(mask_positions):