Denvis

I want to develop an application that takes a string of letters (A-Z) and spit out all the possibilities in terms of combinations we can make based on that string.

My software design teacher created an algorithm that does exactly that (4 characters, but can be changed).

^ the above is pseudocode

Basically, he designed it so that it makes all the possible combinations out of 4 numbers, and then use those numbers to selectively pick letters of the input word to create 24 combinations (there will be repeats)

I made my own however it seems to be missing a few combinations (removes repeats)

One seems to not work at all (at least with 4 + char strings) and the other one works but seems inefficient and long. I want to know if there are any other possible ways to do this... if you could respond using pseudocode i'd be very grateful!

My software design teacher created an algorithm that does exactly that (4 characters, but can be changed).

Code: |

begin index = 1 for x=1 to 4 for y=1 to 4 for z=1 to 4 for w=1 to 4 if x+y+z+w=10 and x*y*z*w=24 then list(index) = 1000*x+100*y+10*z+w index=index+1 end if next next next next input WORD for loop = 1 to 24 x=mid(list(loop),1,1) REM assuming you can pull digits out of a number like letters out of a word. y=mid(list(loop),2,1) z=mid(list(loop),3,1) w=mid(list(loop),4,1) anagram(loop)=mid(word,x,1)+ mid(word,y,1)+ mid(word,z,1)+ mid(word,w,1) next end |

^ the above is pseudocode

Basically, he designed it so that it makes all the possible combinations out of 4 numbers, and then use those numbers to selectively pick letters of the input word to create 24 combinations (there will be repeats)

I made my own however it seems to be missing a few combinations (removes repeats)

Code: |

begin
input n REM 4 char string original_n = n for x = 0 to length of n for i = 1 to length of n temp = mid(n,x,1) mid(n,x,1) = mid(n,i,1) mid(n,i,1) = temp for y = 0 to length of list() REM no repeats area if n != list(y) AND y = len(list) then REM != is not list(y+1) = n endif next next n = original_n next end |

One seems to not work at all (at least with 4 + char strings) and the other one works but seems inefficient and long. I want to know if there are any other possible ways to do this... if you could respond using pseudocode i'd be very grateful!