Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/articles/cpp-tutorials/)
-   -   All possible combinations of a string (http://www.go4expert.com/articles/combinations-string-t227/)

radams 7May2008 01:22

Re: All possible combinations of a string
 
Hate to tell you this but this code doesn't generate all possible combinations. Upon testing the code and converting it for java I have discovered that is duplicates combinations. I put in the word "abcd" and it generates the same "abcd" twice. It seems to work fine for 3 letter words. There is clearly a bug in the code.

anjanesh 9Mar2015 18:07

Re: All possible combinations of a string
 
I just ran this code in HTML + Javascript and this is what I got for abcd.
Code:

abcd
abdc
acbd
acdb
adbc
adcb
badc
bacd
bcda
bcad
bdca
bdac
cabd
cadb
cbad
cbda
cdab
cdba
dacb
dabc
dbca
dbac
dcba
dcab

There is just one occurance of abcd.


All times are GMT +5.5. The time now is 03:01.