JavaScript Permutation Calculator and Generator:

String to permute: Delimiter (permutation separator):
Use the pre-generated permutations page for more flexibility.

Here is the JavaScript source code for the permutation algorithm (from permute.js):
//permArr: Global array which holds the list of permutations
//usedChars: Global utility array which holds a list of "currently-in-use" characters
var permArr = [], usedChars = [];
function permute(input) {
  //convert input into a char array (one element for each character)
  var i, ch, chars = input.split("");
  for (i = 0; i < chars.length; i++) {
    //get and remove character at index "i" from char array
    ch = chars.splice(i, 1);
    //add removed character to the end of used characters
    usedChars.push(ch);
    //when there are no more characters left in char array to add, add used chars to list of permutations
    if (chars.length == 0) permArr[permArr.length] = usedChars.join("");
    //send characters (minus the removed one from above) from char array to be permuted
    permute(chars.join(""));
    //add removed character back into char array in original position
    chars.splice(i, 0, ch);
    //remove the last character used off the end of used characters array
    usedChars.pop();
  }
}
You may be asking yourself, “why should I care about this?” Permutations are often used to solve programming problems. Programmers often employ permutations and combinations when they want to solve a problem with brute force. Here's are some articles that explain good uses for permutations with examples:
Some advice to any beginning CS student unfortunate enough to be assigned the Traveling Salesman Problem... Don't attempt to use the brute-force permutation technique for any more than about 12 cities (trust me on this, it has a big O of n factorial where n is the number of cities!)

Go to Scriptar.com Home | Alternate JS Permutation Technique | Combinations