solver

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 2 Imported by: 0

README

Solver

Think the "official" word list is missing a valid four letter word? Create an issue/merge request!

How does this work?

  • Creates a bi-directional graph with the words list (either provided or the default set) by linking words that are one letter off from one another
    • With list: 'head', 'hear', 'heat', 'mead', 'meat', this graph would be created:
    head --- meat
      |       |
    head --- mead
      |
    hear
    
  • Once the graph is created, the shortest path between from and to is found. This is done by the github.com/yourbasic/graph package
IRIFWMTM

(Interesting Reads I Found While Making This Module)

Learnings
  • When you make a module, go mod init when you first make the project, and then go mod tidy every once in while when you have removed/added/changed your deps, this auto updates it.
  • After that, run go build to create a go sum
  • Run go test to run the tests
       ______  _____   __     _   _    ____   ____
      / ----,' / _  / / /    / / / / / ___/ /  o  )
      ---,  / / // / / /__  / /_/ / / __/  / ___ i
     /_____/ /____/ /____/ |_____/ /____/ /_/  /_/
     

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Solve

func Solve(from, to string, arr []string, stringLen int) ([]string, int64, error)

Params:

from: string, the word to start from. Needs to have the same length as to
to: string, the word to get to. Needs to have the same length as from
wordsList: []string, a list of string that can be used as steps to get to 'to' from 'from', MUST be the same length as them
	- Solver expects the wordsList to only include words that are of len 4

Returns:

The solution, the number of words it takes, or an error

Types

This section is empty.

Jump to

Keyboard shortcuts

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