Tech Simple

I have been in so-called high-tech for more than 25 years, and I’ve worked with labor and time-saving software and hardware—and I’ve wasted a lot of time, too, often laboring long days and weeks with little to show for it outside of that ephemeral favorite, the wisdom of experience.

This blog is my celebration of the adage: Keep it simple, stupid. I intend to apply this discipline to technical challenges low and high, in a way that's both clear and entertaining.

We all have to find ways not only to understand the technology that surrounds us, but to bend it to our will, to be masters of our time and talent, and protect our most valuable asset: our time.

Welcome to you, I hope you find the information I post here useful.

Wednesday, February 18, 2009

My Favorite Algorithm

There are algorithms for everything.

My favorite represents a combination of numbers in a single number. The value of that number is determined as the sum of all 2 ** (N-1) for each N included in the set.

For example, the set containing 1, 7, and 11 is:

(2**0) + (2 ** 6) + (2 ** 10) = 1089
(1) + (64) + (1024) = 1089

This algorithm was particularly useful when computer space and processing time were at a premium. But even today, it’s cool to be able to “say” several specific things with a single number.

The way it works is that each combination will have its own unique number, no matter how many items are in the set, using powers of 2.

Best to limit the range of “N” so you can decode your result number expediently. The software I know that employed this algorithm used it for a range of 1 to 15.

No comments:

Post a Comment