# Create Unique ID

• May 30th 2005, 03:06 AM
DeNutza
Create Unique ID
If I have 3 groups: each holding a distinct # of combinations:

Group A(1 to 3) B(1 to 2) and C(1 to 3)

How can I create a unique "sequential" ID for each unique
possibility? (There are 18 possibilities in this example,
so I would need an ID from 1 to 18 for each one)

so from 1 to total # of combinations as the ID.

Also note if A= 1, B=1, C=2 you cannot simply multiply since
if A=2, B=1, C=1 it produces the same ID.

Your help is appreciated.
• May 31st 2005, 07:21 AM
hpe
Suppose you have an element with groups A=a, B=b, C=c.

Use the formula x = (a-1)*6 + (b-1)*3 + (c-1) to make an identifier x between 0 and 17.

This is unique: To recover (a,b,c) from x, first divide x by 6 with remainder, x = 6z+y. Then a = z+1. Next divide y by 3 with remainder, y = 3t+r. Then b = t+1 and c = r+1.

Example: A-group = 2, B-group = 1, C-group = 3. Then a = 1, b = 0, c = 2, and x = 6 + 2 = 8. To recover a, b, and c, you can compute

8 = 1*6 + 2, so a = 1+1 = 2.
2 = 0*3 + 2, so b = 0+1 = 1 and c = 2+1 = 3.