0.0.3-alpha.0 • Published 5 years ago

@gogen-solver/core v0.0.3-alpha.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

@gogen-solver/core

The core algorithm to solve Gogen puzzles with. For more info about what a Gogen puzzle is, please see the README.md in the repo root.

Install

  • yarn:yarn add @gogen-solver/core
  • npm:npm install @gogen-solver/core

Usage:

Please see underneath for examples.

ConstructorDescription
Gogen(grid: array[], words: string[])Creates a new puzzle instance.
MethodDescription
solvesolve() solves the puzzle, assuming initialised with valid words and grid. The result is available in .grid.graph.

Example

This uses an example from London Evening Standard (26th Jan 2018):

const Gogen = require('@gogen-solver/core');

const words = [
    "BUG",
    "CLING",
    "DAMPING",
    "FOIL",
    "FOX",
    "HARM",
    "HAVOC",
    "JAM",
    "KEY",
    "PEW",
    "SQUINT",
    "YEW"
  ];

const grid = [
 ["Y", "_", "W", "_", "H"],
 ["_", "_", "_", "_", "_"],
 ["Q", "_", "X", "_", "D"],
 ["_", "_", "_", "_", "_"],
 ["T", "_", "G", "_", "C"]
];

const puzzle = new Gogen(grid, words);

puzzle.solve();
console.table(puzzle.grid.graph)