npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

solve-boggle

v3.0.1

Published

Solve Boggle boards by finding every English word in them.

Downloads

8

Readme

Node Boggle Solver

Using JavaScript to generate a Boggle board and then find every English word in that board. All the words are stored in a trie for efficiency. Use as a command line tool or a NodeJS module.

npm install solve-boggle

Boggle solver module

You can supply the letters to the board in the constructor.

const Boggle = require('solve-boggle');

let boggle = new Boggle('adofhptogijrstjg'); // letters for 4x4 board from left-to-right then top-to-bottem
boggle.solve(words => {
  boggle.print(); // format the board nicely
  // "words" is an array of the board's words. It is now also referenced as boggle.words
  console.log(words.length + ' words');
  console.log(words.join(', '));
});

The board can theoretically be any NxN size. This is efficient enough to handle 200x200 boards in less than a second. They can be generated randomly from the boggle dice if N is between 4 and 6 inclusive.

const Boggle = require('solve-boggle');

let boggle1 = new Boggle('CLEINRTSHBNFAOUIEERGTPUNE'); // 5x5 board
let boggle2 = new Boggle('sdjgneraghpareugnaeporigrpeouganerkgjarpehgaeraetusnviehtvndjfgd'); // 8x8 board

let boggle3 = new Boggle(6); // roll the dice for a 6x6 board
let boggle4 = new Boggle(5);
let boggle5 = new Boggle(); // defaults to 4

Check for individual words in the board.

let boggle = new Boggle('eorgvregearjkgoe');
boggle.contains('grave', result => {
  console.log(result); // true
});
boggle.contains('randomstuff', result => {
  console.log(result); // false
});

Boggle solver CLI

The argument to the command is the same as the argument you would be giving to the Boggle constructor function.

node_modules/.bin/solve-boggle erogijeratierstp
┌───┬───┬───┬───┐
│ E │ R │ O │ G │
├───┼───┼───┼───┤
│ I │ J │ E │ R │
├───┼───┼───┼───┤
│ A │ T │ I │ E │
├───┼───┼───┼───┤
│ R │ S │ T │ P │
└───┴───┴───┴───┘

103 words

AIR, ATE, ART, ERE, EGO, ERG, ETA, GET, GEE, IRE, ITS, JAR, JOG, JET, ORE, PER, PIS, PIT, PEE, PET, PIE, RAT, REP, RIP, ROE, SIP, SIR, SIT, SAT, TEE, TAR, TIP, TIE, TIT, ARTS, ERGO, GRIP, GRIT, GORE, GETS, JEEP, JEER, JETS, JARS, OGRE, PETS, PIER, PITS, PITA, PEER, RATE, RATS, RIPE, RITE, REIS, SATE, STIR, SIRE, STAR, SITE, STEP, TITS, TSAR, TARS, TIRO, TIRE, TIER, ASTER, ASTIR, EERIE, EGRET, GRIST, GRITS, GREET, GRIPE, ROGER, STEER, SITAR, STAIR, STEEP, TASTE, ATTIRE, ARTIER, ARTIST, EGRETS, GREETS, GORIER, PETITE, RASTER, REGRET, RETIRE, SATIRE, SITTER, STEREO, TASTER, ARTSIER, ARTISTE, PETTIER, REGRETS, RATTIER, TASTIER, GRITTIER, JITTERIER

Instead, you can install globally...

npm install -g solve-boggle

and invoke the command like this.

solve-boggle erogijeratierstp

Documentation

Boggle

Class representing a Boggle board.

Kind: global class

new Boggle([boardParam])

Create an NxN board.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [boardParam] | string | number | 4 | Either a string with the board's letters (left-to-right top-to-bottom), or a size N. |

boggle.print()

Format the board as a string and write to stdout.

Kind: instance method of Boggle

boggle.toString()

Convert the board to a string.

Kind: instance method of Boggle

boggle.solve(done)

Finds all English words in the board.

Kind: instance method of Boggle

| Param | Type | Description | | --- | --- | --- | | done | solveCallback | Callback to run when done solving. |

boggle.contains(target, done)

Finds one English word in the board.

Kind: instance method of Boggle

| Param | Type | Description | | --- | --- | --- | | target | string | Word to search for in the board. | | done | containsCallback | Callback to run when done verifying. |

Boggle~solveCallback : function

Callback to run when done solving.

Kind: inner typedef of Boggle

| Param | Type | Description | | --- | --- | --- | | words | array | Array of the words in the board. |

Boggle~containsCallback : function

Callback to run when done verifying.

Kind: inner typedef of Boggle

| Param | Type | Description | | --- | --- | --- | | found | boolean | Whether or not the word was found in the board. |