Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
Algorithms
Hi, Have you learnt permutations and combinations in Math? well, like with 1,2,3 you can make 6 combos. with 4 you can make 24. Is that what you mean? You can find it by finding n! (n factorial). It means 1x2x3x4x…….xn.
A simple loop would be:
$fact=1; for($i=1;$i<=$n;$i++) $fact*=$i;
At the end of that $fact will have the factorial of n. Is that what you wanted?
ThomasB)
There are a few ways that you could solve this. I'd recommend using recursion to get the job done. Off the top of my head with no testing, so bear with me.
pseudo code:
if (!n--) return false; //controls the end of recursion
for each piece of data { //loop through each piece of data (1,2,3 in your example)
foo=x.data_piece; //create the possible solution such as 11,12,13,111,112, etc
generate(data,foo,n); //generate the next set
}
}
generate(array(1,2,3,4),'',7); //generate data until length=7
HTH
ps. sorry, the code parser appears to be non existant on here