equation to create unique value

I have a list of n objects

say [ apple, orange, carrot, cherry, banana ]


Now I am trying to come up with an equation which will generate an unique number for each combinations from this list.

eg :

say I assign following values for each items

apple = 1
orange = 2
carrot = 3
cherry = 4
banana = 5


If I directly add the individual values to generate combination score then the values will be

apple      = 1
apple, carrot = 4
apple, orange = 3


But here multiple combination can have same scores.

I need to generate an equation which will generate UNIQUE score for all of these combination.

POSITION IS NOT AN ISSUE.

Score(apple,orange,carrot) = Score(carrot, apple, orange) = Score (orange, apple, carrot)

But Score (apple, carrot) $\ne$ Score(cherry)

How this can be generated ?

• Welcome to math.SE: since you are new, I wanted to let you know a few things about the site. In order to get the best possible answers, it is helpful if you write what your thoughts are on the problem and include your efforts (work in progress) in this and future posts; this will prevent people from telling you things you already know, and help them give their answers at the right level. – JKnecht Feb 5 '16 at 12:21
• Why not just combine them into a single number, e.g. apple, orange and carrot ($1$ and $2$ and $3$) becomes $123$. Or, mathematically, multiply each number with $10^i$, with $i$ their position, starting count at $0$. – Eric S. Feb 5 '16 at 12:46
• Eric, then apple, orange and carrot (1 and 2 and 3) = 123 and orange, apple and carrot (2 and 1 and 3) = 213 are not equal – Sreejithc321 Feb 6 '16 at 10:47

Assign a prime number to each object.

Let the score for each combination be the product of the prime numbers assigned to the objects in the combination.

This will also allow you to use the score to record multiple occurrences of items (if you want).

Every such score created can be uniquely factorised to identify the items in your list.

• Yes this works, thank you. Is there a better way if the number of objects in list > 10000. Because then the product will be so huge. – Sreejithc321 Feb 5 '16 at 12:53
• That's because the number of different combinations is so large! – tomi Feb 5 '16 at 14:54
• yes but still can this value be reduced some how ? – Sreejithc321 Feb 8 '16 at 10:30
• How many objects are there likely to be in a typical "combination"? Do certain objects appear more frequently? Are there some pairings that appear more frequently than others? Are there some prohibited pairings? – tomi Feb 8 '16 at 10:40

Perhaps I'm missing something, but it sounds as if all you want is to assign each element a unique exponentiation of a base value; for example,

• apple = 1 i.e. $2^0$
• banana = 2 i.e. $2^1$
• cherry = 4 i.e. $2^2$

etc. Then any way you add them, you can always decompose the sum. More simply:

• apple = 1
• banana = 10
• cherry = 100
• Welcome to math.SE! See this guide for how to mark up math nicely on this site. – Frentos Feb 5 '16 at 12:35