1.0.4 • Published 10 years ago

palindrome-solver v1.0.4

Weekly downloads
8
License
MIT
Repository
github
Last release
10 years ago

#Palindrome-solver

Get every possible palindrome within a word

##Example

var PSolver = require('palindrome-solver');

var word = "anna";

var solver = new PSolver();

solver.palindromes(word, function(answer) {
  //answer is an array
  console.log(answer.type, '('+ answer.result.length +')-->', answer.result);
});

// palindromes run time: 0ms
//
// palindromes (4)--> [ 'ana', 'nan', 'anna', 'naan' ]

solver.combinations(word, function(answer) {
  //answer is an array
  console.log(answer.type, '('+ answer.result.length +')-->', answer.result);
});

// combinations run time: 0ms
//
// combinations (18)-->
// [ 'a',
//   'n',
//   'an',
//   'aa',
//   'na',
//   'nn',
//   'ann',
//   'ana',
//   'aan',
//   'nan',
//   'naa',
//   'nna',
//   'anna',
//   'anan',
//   'aann',
//   'nana',
//   'naan',
//   'nnaa' ]

##Performance

Finding all permutations of a word is O(n!) where n is the number of characters in the word. You've been warned.

##Combinations

Only unique combinations are returned. Max possible combinations is N!.

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago