Brute Force Algorythm
I have been trying to make a program that just spits out every possible combinations in the char list i specify and the length i specify. The problem is that I cant think of a decent alg for it. I have read about it and stuff but I just cant sem to find a way to do it. The only way I can think of doing it is by making a ton of integrated for loops which is totally wrong and inefficient. How can I do this? Thanks...
Example:
Number Of Chars: 4
Pattern List: 0123456789
Output:
0000
0111
0011
1111
0112...etc except with all the numbers and stuff.
[610 byte] By [
Sucka8a] at [2007-11-26 20:49:09]

> 0000
> 0111
> 0011
> 1111
> 0112...etc except with all the numbers and stuff.
Why not
0000
0001
0002
...
0009
0010
0011
0012 etc. ?
Use the digits as indices to the array with the characters and just use some loops to do the trick.
A tree data structure would fit this problem.
Attach all possibilities for the first digit to the top node of the tree, and attach a node for each possibility for the second digit to each node of the first digit layer of the tree, etc.This way, if you need to add a digit, you simply stick another layer onto the tree.
Do a pre-order traversal of the tree to get your sorted list.
Can't find any examples off hand.