solver

package
v0.0.0-...-b4794de Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 7 Imported by: 0

README

Find initial set of Possible Letters

The possible letters for a tile are given as the set:

pl := g | w + yd - w(row) - w(col) + y(row) + y(col) - ws

The match instruction for a word is given as:

mi := [pl1][pl2][pl3][pl4][pl5] | egrep [ye]

Where:

  • g = self is green
  • w = {all white tiles}
  • yd = {all yellow duplicates}
  • w(row) = {all white tiles in this row}
  • w(col) = {all white tiles in this col}
  • y(row) = {all yellow tiles in this row}
  • y(col) = {all yellow tiles in this col}
  • s = self
  • ye = any yellow letters in non-intersection tiles

Reduce that set by any that have already been assigned

Once the sets of possible letters (pl) for each tile have been found, take the set of all starting letters and subtract all letters that have a known position (a set size of one). The remainder will be the letters that can still be used. Any possible letter that is not in that set can be eliminated.

Reduce that set again by valid words

Map each word's sets of possible letters against a broad dictionary. Reduce the 'pl' sets to the sets of letters in the matches.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSolution

func ParseSolution(puzzle, solution string) string

ParseSolution returns the serialization of the game given a puzzle and a solution

Types

type Possibles

type Possibles [][][]rune

type Solver

type Solver struct {
	// contains filtered or unexported fields
}

func New

func New(w board.Waffle) Solver

New creates an empty waffle game solver

func (*Solver) Get

func (s *Solver) Get(row, col int) (rune, rune)

Get returns the letter and color at row, col

func (*Solver) GetSolution

func (s *Solver) GetSolution(row, col int) rune

GetSolution returns the solution letter and color at row, col

func (*Solver) Print

func (s *Solver) Print()

Print prints a representation of the solver state to the console

func (*Solver) Serialize

func (s *Solver) Serialize() string

Serialize returns the solution as a string

func (*Solver) Set

func (s *Solver) Set(row, col int, l, c rune)

Set sets the letter and color at row, col

func (*Solver) Size

func (s *Solver) Size() int

Size returns the size of the waffle game board

func (*Solver) Solve

func (s *Solver) Solve() bool

Solve solves the waffle board game

func (*Solver) Solved

func (s *Solver) Solved() bool

Solved returns true if the waffle game is solved

func (*Solver) Tiles

func (s *Solver) Tiles() []board.Tile

func (*Solver) TilesInCol

func (s *Solver) TilesInCol(row, col int, matchColor rune) map[rune]int

TilesInCol returns the set of letters of a given color (and their count) adjacent to the given coord

func (*Solver) TilesInRow

func (s *Solver) TilesInRow(row, col int, matchColor rune) map[rune]int

TilesInRow returns the set of letters of a given color (and their count) adjacent to the given coord

func (*Solver) WhiteTiles

func (s *Solver) WhiteTiles() map[rune]int

WhiteTiles returns the letters on all of the white tiles

func (*Solver) YellowDupes

func (s *Solver) YellowDupes() map[rune]int

YellowDupes returns any yellow tile letters that are duplicates of each other

func (*Solver) YellowEvenCol

func (s *Solver) YellowEvenCol(i int) []rune

YellowEvenCol returns the letters on yellow tiles in non-intersections for the given col

func (*Solver) YellowEvenRow

func (s *Solver) YellowEvenRow(i int) []rune

YellowEvenRow returns the letters on yellow tiles in non-intersections for the given row

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL