see topic nuff said
see topic nuff said
do you want a random set or every single set??
every single set and in alphabetical order...
I think that u would use nested for loops with numbers and comvert the numbers into the corresponding ascii character. not too sure if this would work because I am not familiar with the ascii character codes.
Um, you realize that there are an infinite number of letter/number combos?
"No! I must have my delicious cupcakes, my sweet cakey treasures, piping hot from their 40 watt WOMB!!!"
--Captain Murphy
As far as I know, due the fact JTtheCPPgod pointed out there is no "best" algorithm. Perhaps add some restrictions like length. Then the job becomes a little bit easier.
This code will print out all possible permutations of the string input
The input string must be sorted in value from lowest to highest (ascii value ) You can use the sort function if you need to sort the inputCode:#include <iostream> //for cout #include <string> //for string #include <algorithm> //for next_permutation using namespace std; int main() { string input = "abcdef"; while( next_permutation( input.begin() , input.end() ) ) { cout << input << endl; } return 0; }
I was assuming that there was a set length that was desired. If not, then ur program will never even finish its first set
Are you refering the code i posted? The next_permutation calculates the next highest permutation of the data you send it, using the < operator. so the permutation 012 is less than 102 which is less than 210.Originally posted by golfinguy4
I was assuming that there was a set length that was desired. If not, then ur program will never even finish its first set
Once it get to the final permutation it will return false and exit the loop
You will have to set a length on your string. Then there is a finite amount of permutations. For instance if you want to find out how many combos of numbers there are in 5 numbers ranging from 0 to 100 you would do this:
100*99*98*97*96*95.
This assumes that no number can be repeated in the sequence.
Otherwise it would be 100*100*100*100*100.
So if you have 52 letters (26 uppercase and 26 lowercase) and ten numbers you have 62 total characters to choose from. Assuming you want 10 values in the sequence (non-repeating) you would do 62*61*60*59*58*57*56*55*54*53*52 or 62!-52!.
So for non repeating sequences the equation is
MaxNum!-((MaxNum-NumberOfValues)!)
I wasn't talking about ur code RPImatty. I was saying that if he wanted every possible set of characters and numbers without using an input, he would have to create a set length or the program would never finish with the first item.