?
Solved

3 Character  Permutation Algorithm

Posted on 2007-10-05
5
Medium Priority
?
1,047 Views
Last Modified: 2008-05-05
I am trying to figure out how to do what I think is a permutation.  I need to develop an algorithm to calculate all the different possibilities of a 3 character in length string with containing the characters 0-9 and A-Z in each of the 3 positions.  For instance like the following.  (I hope you get the gist of what I need)

A00  A10   A11            B00  0A0
A01  A20   A12            B01  0B0
A02...A30.. A13.........  B02   0C0

But all the different sequences of 36 characters 0-9 A-Z

0
Comment
Question by:searchei
  • 2
  • 2
5 Comments
 
LVL 51

Assisted Solution

by:Ted Bouskill
Ted Bouskill earned 400 total points
ID: 20026582
This is a simple math function.  For example, in binary you have two possible characters for 3 locations is (2 ^ 3) = 8  000, 001, 010, 100, 011, 110, 101, 111

In your case you have 36 possible characters for 3 positions (36 ^ 2) = 46656
0
 
LVL 51

Expert Comment

by:Ted Bouskill
ID: 20026584
Oops there was a typo (36 ^ 3) = 46656
0
 
LVL 85

Expert Comment

by:ozo
ID: 20026611
It sounds like you want to count to 36 in 3 nested loops
0
 
LVL 2

Accepted Solution

by:
zvmrws earned 1600 total points
ID: 20026629
tedbilly is correct for the count of them.

If you want to generate/print them then something like this could be used:

int main(int argc, char *argv[])
{
    int i,j,k;

    char list[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    for (i=0; i<36; i++)
    for (j=0; j<36; j++)
    for (k=0; k<36; k++)
    {
        printf("%c%c%c\n",list[i],list[j],list[k]);
    }
    return 0;
}


0
 
LVL 2

Expert Comment

by:zvmrws
ID: 20026796
OK, Thanks.  Here's a bonus for you if you want to do this with a string:

int main(int argc, char *argv[])
{
    int i,j,k;

    char list[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    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_result);   /* Print xyz */
            }
        }
    }
    return 0;
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The greatest common divisor (gcd) of two positive integers is their largest common divisor. Let's consider two numbers 12 and 20. The divisors of 12 are 1, 2, 3, 4, 6, 12 The divisors of 20 are 1, 2, 4, 5, 10 20 The highest number among the c…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question