1
$\begingroup$

I am wanting to represent the state/information of an object using only a single integer.

The encoding algorithm has no limits.

However, the decoding algorithm can only use modular arithmetic and Boolean algebra (AND, OR, NOT). It has an internal lookup table that it knows how to get certain properties out of an integer.

For example, lets say I am describing an apple. There are three properties I want to use to tell me about the apple. A) Color B) Taste C) Origin

The color lookup table could be

1 = Red
2 = Orange
3 = Green
4 = Other

The taste lookup table could be

1 = Sweet
2 = Sour

the Origin lookup table could be

1 = Asia
2 = North America
3 = Europe

If I wanted to describe a Red, sweet apple from Europe I would take (1, 1, 3) and encode it in some way to be decoded using the remainder after a division.

As an bad example lets say encoding was color + (4+taste) + (6+origin).

Therefore the integer would be 1+(4+1)+(6+3) = 15

The decoding algorithm has access to all the lookup tables described above (so it know how to understand what numbers refer to what property values) but it also has a lookup table that defines what it has to mod by in order to get a specific property.

Such a table could be (this only works for this one specific example)

Color = 2
Taste = 7
Origin = 12

Then the following decoding takes place to find the original properties that describe the object:

15 % 2 = 1 (color is red)
15 % 7 = 1 (taste is sweet)
15 % 12 = 3 (origin is europe)

The mod lookup table was specific to the example and doesnt work generically. I am having a hard time finding a encoding/decoding algorithm that can do this. Ideally, this operation would be a single mathematical operation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.