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