hi guys,

i need help on algorithm to combine letters from a word. for example, i have this word: 'ABCD' . then i want to combine 3 letters from that word. so it comes to these combination:
1- ABC
2- ABD
3- ACD
4- BCD

how is the algorithm in java script so that i can get any letter combination from any word insert by users?
real need it urgent....please and thanks in advance

first of all, start with realizing that Java and JavaScript are not one and the same thing. The first is a programming language, in which you can create autonomous applications, the latter is a scripting language, which is (usually) ran within an html page that's loaded in a browser.

the second thing for you to understand, is that this is not "developers for hire". we will help you improving and correcting your code, but we won't write it from scratch for you.
first you put in some effort, then we might.

The way to think of this is to use an array the size of your expected results that consists of indexes into your original word, then systematically increment the indexes until you have every possible arrangement of the letters. Each index in the array indicates what letter of the original word should be produced eacg time.

For each arrangement of index values, check that there are no duplicate indexes; in which case, produce the next output word. Then increment the last index; if it goes over the length of the original word, reset it to 0 and increment the previous index. Keep going until you do not reset an index, or there are no more indexes.

This article has been dead for over six months. Start a new discussion instead.