filter_guess: Filter dictionary of target words using Wordle logic

View source: R/filter_dictionary.R

filter_guessR Documentation

Filter dictionary of target words using Wordle logic

Description

Restrict original dictionary of possible words to those that meet criteria based on information about letters that are correct, incorrect, or misplaced in the unknown target word.

Usage

filter_guess(
  dict = NULL,
  guess = NULL,
  target = NULL,
  correct = NULL,
  incorrect = NULL,
  misplaced = NULL,
  hide = TRUE
)

Arguments

dict

Vector of strings of possible words to match. If NULL, uses dictionary as default.

guess

String of guessed word

target

If provided, word to use as comparison to guess to determine which letters are correct, incorrect, misplaced. If not specified, at least one of correct, incorrect, or misplaced must be specified.

correct

Vector of integers indicating the index position of all correct letters in guess

incorrect

Vector of integers indicating the index position of all incorrect letters in guess

misplaced

Vector of integers indicating the index position of all misplaced letters in guess

hide

If TRUE, return number of words remaining after filtering. If FALSE, return vector of remaining words themselves.

Value

Either a vector of words remaining after filtering or integer indicating the number of words remaining.

Examples

target <- "tangy"
guess <- "tonal"

filter_guess(
  guess = guess,
  target = target
)

filter_guess(
  guess = guess,
  correct = c(1, 3),
  incorrect = c(2, 5),
  misplaced = 4
)

robe2037/wordle documentation built on March 2, 2023, 2:18 a.m.