Saturday, January 11, 2014

Integers Compression - Number Pairing

I ran into a problem where-in I wanted to persist multiple status codes into one integer for optimizing space. I thought about the problem more and ended up with potential solutions which could potentially leverage bit arithmetic of integers, but the solution was not generalized.

I eventually stumbled on this article on wiki http://en.wikipedia.org/wiki/Pairing_function which talked about a general mathematical function to represent multiple numbers using a single number. I could imaging applications of this approach in multiple scenarios such as caching sequences, compressing collections etc.

No comments:

Post a Comment