juzerali / word-transformer

Solution to word transformation problem. Given a dictionary of words, transform one word to another with each transformation being a word in given dictionary

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transformer

Given a dictionary, a source word and destination word, find a path from source to destination that goes through word transformations. The transformation of a word defined as follows.

  • Word in dictionary that can be generated by removing one letter from given word
  • Word in dictionary that can be generated by replacing one letter with another
  • Word in dictionary that can be generated by adding one letter at any place

Requirements

nodejs, https://nodejs.org

Installation

npm install word-transformer

Testing

See file client.js

node ./client.js

API

var TransFormer = require('word-transformer');
var transformer = new Transformer('/usr/share/dict/cracklib-small'); // This might take a while, it creates the dictionary graph

transformer.transform('cap', ate) // -> [ 'cap', 'cape', 'ape', 'ate' ]

TODO

  1. Facade classes that can create transformer instance from other data formats (in-memory Array, json file)
  2. tests

About

Solution to word transformation problem. Given a dictionary of words, transform one word to another with each transformation being a word in given dictionary


Languages

Language:JavaScript 100.0%