Wordler.Puzzle (Wordler v0.1.1) View Source

Functions for solving Wordler puzzles.

Link to this section Summary

Functions

Handle the results of a guess.

Creates a new blank puzzle.

Generate the next guess for a given puzzle.

Link to this section Types

Specs

t() :: %Wordler.Puzzle{
  guessed_letters: MapSet.t(integer()),
  guesses: [binary()],
  rejected_letters: MapSet.t(integer()),
  solution: binary(),
  solution_antipositions: [MapSet.t(integer())],
  solution_list: [binary()],
  solution_members: MapSet.t(integer()),
  solution_positions: [nil | integer()],
  word_list: [binary()]
}

Link to this section Functions

Link to this function

handle_guess(puzzle, guess, letter_results)

View Source

Specs

handle_guess(t(), binary(), [true | false | binary()]) :: t()

Handle the results of a guess.

Returns a new Puzzle with updated constraints and reduced word counts.

Examples

iex> puzzle = Wordler.Puzzle.new()
%Wordler.Puzzle{word_list: [], ...}
iex> length(puzzle.solution_list)
4594
iex> guess = Wordler.Puzzle.new_guess(puzzle)
"irate"
iex> results = [true, "r", false, false, false]
[true, "r", false, false, false]
iex> puzzle = Wordler.Puzzle.handle_guess(puzzle, guess, results)
%Wordler.Puzzle{word_list: [], ...}
iex> length(puzzle.solution_list)
95

Creates a new blank puzzle.

Examples

iex> Wordler.Puzzle.new()
%Wordler.Puzzle{word_list: [], ...}

Specs

next_guess(t()) :: binary()

Generate the next guess for a given puzzle.

Returns a binary string guess. Will return an "exploratory guess" if possible, covering new unguessed letters, or fall back to a "solving guess" if no exploratory guesses are possible.

Examples

iex> Wordler.Puzzle.new()
|> Wordler.Puzzle.new_guess()
"irate"