English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

From within JavaScript, I need an array of all of the words that can be made from some random letters. Also, I need all of the possible combinations of letters (even if they are not words.) It would be great to find a code example written in JavaScript that (quickly) calculates string permutations. However, it doesn't seem too practical to place an entire dictionary into a page for the anagram part; so I am thinking it would be best to use JSON and download the results. Is there a public web service that will accept a string (let's say up to seven characters since 7! or 5040 permutations is not unreasonable) and return all anagrams and/or permutations of that string in JSON format?

2007-01-30 11:28:16 · 3 answers · asked by §©®Î¶†Δ® 4 in Computers & Internet Programming & Design

3 answers

playing scrabble? I know of several sites where I can enter my hand and get back the best words!!!
http://www.google.com/search?q=dictionary+scrabble+anagram
will get you to them!

2007-01-30 12:23:01 · answer #1 · answered by jake cigar™ is retired 7 · 0 1

Here's something I made quite some time ago. There are probably better ways to do this, although this is what I came up with. Truth be told, it's a poor example of using recursion since it doesn't exit anywhere. If you were to port it to a program like C++, I would convert the recursive function to a WHILE loop.

I have seen online anagram services but I forgot the addresses. All the ones I have seen never returned all the possible words though. They limited themselves to the first 2500 words found, give or take.

A quick Google of "anagrams" should return a lot of sites that do server-side processing of anagrams.


function fncGetSequences( aryBodyTemp, aryHeadTemp) {

if( !aryHeadTemp) {
aryHeadTemp = new Array();
}

for( var index= 0; index< aryBodyTemp.length; index++) {
aryBody = aryBodyTemp;
aryHead = aryHeadTemp;

aryHead = aryHead.concat( aryBody.slice( index, index+1));
aryBody = aryBody.slice( 0, index).concat( aryBody.slice(index+1));

if( aryBody.length == 0) {
document.write( aryHead.join("") + "
");
}

fncGetSequences( aryBody, aryHead);
}
}

// CHANGE LETTERS HERE.
var strSequence = "abcde";

var aryParsed = new Array();
for( index= 0; index< strSequence.length; index++) {
aryParsed[ index] = strSequence.charAt( index);
}

fncGetSequences( aryParsed);

2007-01-30 19:47:08 · answer #2 · answered by Kookiemon 6 · 0 1

Maybe you need custom javascript parsing. For example, I am using Smartface App Studio for Standart JSON Parsing with their JSON wizard tools however I may use custom parsing editor using their scripting editor. http://www.smartface.io/benefits-app-studio/

2014-06-24 05:44:04 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers