We need a simple c++ permutations A-Z Algorithm written a certain way.
1. No Recursive functions
2. Must accept N-Length and N-Start for example if I specify in the parameters to start at 4 , and end at 8.
3. Must accept a string for the permutations, if I specify abc123 than it must generate every possible pattern for that string
## Deliverables
Here is a example Algorithm , please note you can not use this code or design your algorithm like this since it does not accept a variable length permutation
int main(int argc, char *argv[])
{
int i,j,k;
char list[]="ABCDEFGHIJKLMNOPQR <wbr />STUVWXYZ01<wbr />23456789";<wbr />
char string_result[4];
string_result[3]=0; /* NUL terminate the string */
for (i=0; i<36; i++)
{
string_result[0]=list[i]; /* Set x__ */
for (j=0; j<36; j++)
{
string_result[1]=list[j]; /* Set _y_ */
for (k=0; k<36; k++)
{
string_result[2]=list[k]; /* Set __z */
printf("%s\n",string_resul<wbr />t); /* Print xyz */
}
}
}
return 0;
}
The thing to realize is that it has a string that it generates permutations from which is what I need.
The requires for Algorithm design or as follows.
1. No Recursive design
2. No STL design
3. Must accept a variable start position and a variable end position
4. If starting from 4th position you can specify which permutation you want to start at, so if I specify the 5th permutation with a permutation string of 01
it would start at 0101
5. Must have one variable it stores results in like below
void output_chars(unsigned int start, unsigned int end,char * ranges)
{
#define CYCLE_RANGE(v1) for(unsigned int j1=0;j1<strlen(ranges);j1++) \
{ \
output[v1] = ranges[j1]; \
std::cout << output << std::endl; \
}
char output[32];
ZeroMemory(output,32);
if(start >=end) return;
for(unsigned int i2 = 0;i2<end;i2++) //reset the string
output[i2] = ranges[0];
unsigned int string_length = 0;
for(unsigned int i = start;i<end;i++)
{
output[i+1]=0; //allocate new memory
string_length = strlen(output);
unsigned int string_pos = i;
while(string_pos)
{
//how many position to the right of me
unsigned int right_pos = i - string_pos;
for(unsigned int r1 = i;r1>string_pos;r1--)
{
for(unsigned int i2 = 0;i2<strlen(ranges);i2++)
{
output[string_pos-1] = ranges[i2];
std::cout << output << std::endl;
}
CYCLE_RANGE(r1)
}
//CYCLE_RANGE(string_pos)
string_pos--;
}
for(unsigned int i2 = 0;i2<end;i2++) //reset the string
output[i2] = ranges[0];
}
return;
}
Notice how it only stores data in the output variable, this is very important and this is how the algorithm should be designed
If you have any questions please let me know and I am willing to pay what ever it takes.