all combination via recursive function

Ads
 

all combination via recursive function

hello

i have a php scrpt which generates all possibilities fro a given string

recursive function is used in it. i have given its code below

$charset = "abcd";


$charset_length = strlen($charset);
define('MAX_LENGTH', 4);
function recurse($width, $position, $base_string) {
    global $charset, $charset_length;

    for ($i = 0; $i < $charset_length; ++$i) {
        if ($position  < $width - 1) {
            recurse($width, $position + 1, $base_string . $charset[$i]);
        }


$string = $base_string . $charset[$i] ;

echo "$string<br/>";

    }
}

recurse (MAX_LENGTH, 0, '');
?>

the output of given code is

aaaa
aaab
aaac
aaad
aaa
aaba
aabb
aabc
aabd
aab
aaca
aacb
aacc
aacd
aac
aada
aadb
aadc
aadd
aad
aa
abaa
abab
abac
abad
aba
abba
abbb
abbc
abbd
abb
abca
abcb
abcc
abcd
abc
abda
abdb
abdc
abdd
abd
ab
acaa
acab
acac
acad
aca
acba
acbb
acbc
acbd
acb
acca
accb
accc
accd
acc
acda
acdb
acdc
acdd
acd
ac
adaa
adab
adac
adad
ada
adba
adbb
adbc
adbd
adb
adca
adcb
adcc
adcd
adc
adda
addb
addc
addd
add
ad
a
baaa
baab
baac
baad
baa
baba
babb
babc
babd
bab
baca
bacb
bacc
bacd
bac
bada
badb
badc
badd
bad
ba
bbaa
bbab
bbac
bbad
bba
bbba
bbbb
bbbc
bbbd
bbb
bbca
bbcb
bbcc
bbcd
bbc
bbda
bbdb
bbdc
bbdd
bbd
bb
bcaa
bcab
bcac
bcad
bca
bcba
bcbb
bcbc
bcbd
bcb
bcca
bccb
bccc
bccd
bcc
bcda
bcdb
bcdc
bcdd
bcd
bc
bdaa
bdab
bdac
bdad
bda
bdba
bdbb
bdbc
bdbd
bdb
bdca
bdcb
bdcc
bdcd
bdc
bdda
bddb
bddc
bddd
bdd
bd
b
caaa
caab
caac
caad
caa
caba
cabb
cabc
cabd
cab
caca
cacb
cacc
cacd
cac
cada
cadb
cadc
cadd
cad
ca
cbaa
cbab
cbac
cbad
cba
cbba
cbbb
cbbc
cbbd
cbb
cbca
cbcb
cbcc
cbcd
cbc
cbda
cbdb
cbdc
cbdd
cbd
cb
ccaa
ccab
ccac
ccad
cca
ccba
ccbb
ccbc
ccbd
ccb
ccca
cccb
cccc
cccd
ccc
ccda
ccdb
ccdc
ccdd
ccd
cc
cdaa
cdab
cdac
cdad
cda
cdba
cdbb
cdbc
cdbd
cdb
cdca
cdcb
cdcc
cdcd
cdc
cdda
cddb
cddc
cddd
cdd
cd
c
daaa
daab
daac
daad
daa
daba
dabb
dabc
dabd
dab
daca
dacb
dacc
dacd
dac
dada
dadb
dadc
dadd
dad
da
dbaa
dbab
dbac
dbad
dba
dbba
dbbb
dbbc
dbbd
dbb
dbca
dbcb
dbcc
dbcd
dbc
dbda
dbdb
dbdc
dbdd
dbd
db
dcaa
dcab
dcac
dcad
dca
dcba
dcbb
dcbc
dcbd
dcb
dcca
dccb
dccc
dccd
dcc
dcda
dcdb
dcdc
dcdd
dcd
dc
ddaa
ddab
ddac
ddad
dda
ddba
ddbb
ddbc
ddbd
ddb
ddca
ddcb
ddcc
ddcd
ddc
ddda
dddb
dddc
dddd
ddd
dd
d

i mean it generates all possibilities from a string "abcd" now i want that this code generate result which must have the possibilites of minimum 3 characters and above

now i want that this code generates all possibilites having minimum three charters like aaa bbb aab acc add abd abc aaaa aaab aaad dabb. i mean the code must ommit all one or two charcter string (i.e., a aa b bb cd dc ......) from the result

how i do that please help

View Answers

September 24, 2012 at 6:22 PM

can anyone write recursive function for generating alphanumeric string ?

Ads









Related Tutorials/Questions & Answers:
all combination via recursive function
all combination via recursive function  hello i have a php scrpt which generates all possibilities fro a given string recursive function... = strlen($charset); define('MAX_LENGTH', 4); function recurse($width
ModuleNotFoundError: No module named 'combination_all'
ModuleNotFoundError: No module named 'combination_all'  Hi, My... named 'combination_all' How to remove the ModuleNotFoundError: No module named 'combination_all' error? Thanks   Hi, In your python
Advertisements
ModuleNotFoundError: No module named 'combination_all'
ModuleNotFoundError: No module named 'combination_all'  Hi, My... named 'combination_all' How to remove the ModuleNotFoundError: No module named 'combination_all' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'combination_all'
ModuleNotFoundError: No module named 'combination_all'  Hi, My... named 'combination_all' How to remove the ModuleNotFoundError: No module named 'combination_all' error? Thanks   Hi, In your python
How ro convert char into string using recursive function in c#??
How ro convert char into string using recursive function in c#??  This coding is for java...but i want this in c# How ro convert char into string using recursive function in c#?? char [] ch={'H','E','L','L','o'}; TO ans
how to print all possible combination that sum to zero??
how to print all possible combination that sum to zero??  ?.... Print all possible combinations that sum to zero Example Enter a num : 7 1... each of the digits so that the resultant sum is zero. Print all posible
JavaScript replaceAll function to replacing all occurrences of a string
JavaScript replaceAll function to replacing all occurrences of a string  Hi, I am new to JavaScript and there is requirement of replacing all occurrences of a string. How make JavaScript replaceAll function to replacing all
JavaScript replaceAll function to replacing all occurrences of a string
JavaScript replaceAll function to replacing all occurrences of a string  Hi, I am new to JavaScript and there is requirement of replacing all occurrences of a string. How make JavaScript replaceAll function to replacing all
JavaScript replaceAll function to replacing all occurrences of a string
JavaScript replaceAll function to replacing all occurrences of a string  Hi, I am new to JavaScript and there is requirement of replacing all occurrences of a string. How make JavaScript replaceAll function to replacing all
Mysql Lpad Function
of the string.The Function stopped the combination of string and added padding... Lpad Function:- The Query below return you the all the letters of roseindia.net... Mysql Lpad Function     
Mysql Lpad Function
Mysql Lpad Function       Mysql Lpad Function is used to add padding to the left end of the string. The Function stopped the combination of string and added padding if it reached
recursive method
recursive method  Write a recursive method to add the first n terms of the series 1 + (1/2) - (1/3) + (1/4) - (1/5
Fibonacci (Recursive)
Fibonacci (Recursive)  I need to write a program for my AP CS class... to do: Assignment: 1.Write a recursive method that takes in a single integer (x.... Instructions: Use these sample run output values: Recursive Fibonacci: 0, 3, 11
function
function  difference between function overloading and operator overloading
ModuleNotFoundError: No module named 'Combination'
ModuleNotFoundError: No module named 'Combination'  Hi, My Python... 'Combination' How to remove the ModuleNotFoundError: No module named 'Combination' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'Combination'
ModuleNotFoundError: No module named 'Combination'  Hi, My Python... 'Combination' How to remove the ModuleNotFoundError: No module named 'Combination' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'Combination'
ModuleNotFoundError: No module named 'Combination'  Hi, My Python... 'Combination' How to remove the ModuleNotFoundError: No module named 'Combination' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'recursive'
ModuleNotFoundError: No module named 'recursive'  Hi, My Python... 'recursive' How to remove the ModuleNotFoundError: No module named 'recursive' error? Thanks   Hi, In your python environment you
Collect Mac Address Connected via Bluetooth
Collect Mac Address Connected via Bluetooth  How to collect automatically all mac address connected via bluetooth and save in a file
ModuleNotFoundError: No module named 'via'
ModuleNotFoundError: No module named 'via'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'via' How to remove the ModuleNotFoundError: No module named 'via' error
xml to html via java
xml to html via java  how to read xml into html using java code
ModuleNotFoundError: No module named 'djangorestframework-recursive'
ModuleNotFoundError: No module named 'djangorestframework-recursive'  ...: No module named 'djangorestframework-recursive' How to remove the ModuleNotFoundError: No module named 'djangorestframework-recursive' error
ModuleNotFoundError: No module named 'djangorestframework-recursive'
ModuleNotFoundError: No module named 'djangorestframework-recursive'  ...: No module named 'djangorestframework-recursive' How to remove the ModuleNotFoundError: No module named 'djangorestframework-recursive' error
ModuleNotFoundError: No module named 'recursive-abc'
ModuleNotFoundError: No module named 'recursive-abc'  Hi, My... 'recursive-abc' How to remove the ModuleNotFoundError: No module named 'recursive-abc' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'recursive-compression'
ModuleNotFoundError: No module named 'recursive-compression'  Hi...: No module named 'recursive-compression' How to remove the ModuleNotFoundError: No module named 'recursive-compression' error? Thanks   Hi
ModuleNotFoundError: No module named 'recursive-decorator'
ModuleNotFoundError: No module named 'recursive-decorator'  Hi, My... named 'recursive-decorator' How to remove the ModuleNotFoundError: No module named 'recursive-decorator' error? Thanks   Hi
ModuleNotFoundError: No module named 'recursive-diff'
ModuleNotFoundError: No module named 'recursive-diff'  Hi, My... named 'recursive-diff' How to remove the ModuleNotFoundError: No module named 'recursive-diff' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'recursive_listfunction'
ModuleNotFoundError: No module named 'recursive_listfunction'  Hi...: No module named 'recursive_listfunction' How to remove the ModuleNotFoundError: No module named 'recursive_listfunction' error? Thanks   Hi
ModuleNotFoundError: No module named 'recursive-parse'
ModuleNotFoundError: No module named 'recursive-parse'  Hi, My... named 'recursive-parse' How to remove the ModuleNotFoundError: No module named 'recursive-parse' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'recursive_print'
ModuleNotFoundError: No module named 'recursive_print'  Hi, My... named 'recursive_print' How to remove the ModuleNotFoundError: No module named 'recursive_print' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'recursive-sgd'
ModuleNotFoundError: No module named 'recursive-sgd'  Hi, My... 'recursive-sgd' How to remove the ModuleNotFoundError: No module named 'recursive-sgd' error? Thanks   Hi, In your python

Ads