Ta946
Ta946

Reputation: 1412

Unique set of numbers, where the sum of any combination will indicate which numbers were chosen in that combination

I've seen this before in a form where, when you select multiple options from a list, each option has a numerical value and the sum of the selected options represents which combination of options were selected. For example:

100= a (black), 43= b (blue), 2= c (green), 4= d (red)

The sum represents which options were picked:

102 = a,c (black, green)
106 = a,c,d
43 = b
149 = a,b,c,d (black, blue, green, red)

Does anyone know the name of this so I can look it up? I have had no luck finding the right terms (I'm assuming it's a form of combinatorics?)

Upvotes: 0

Views: 77

Answers (1)

Andrea Reina
Andrea Reina

Reputation: 1240

Don't know what it's called either, but if you don't allow repeated items you can achieve this with the sequence of powers of two [1, 2, 4, 8, ...]. Getting the individual items that make up the sum is equivalent to getting the binary expansion of the number

a = 1 = b001
b = 2 = b010
c = 4 = b100

1 -> b001 -> a
2 -> b010 -> b
3 -> b011 -> ab
4 -> b100 -> c
5 -> b101 -> ac
6 -> b110 -> bc
7 -> b111 -> abc

Upvotes: 1

Related Questions