Blog Home Portfolio

Published

- 2 min read

Thinking outside base2,10,16..

img of Thinking outside base2,10,16..

Here was the puzzle I faced in my work with proteins. In my dataset, I deal with 24 alphabets: ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘V’, ‘W’, ‘X/*’, ‘Y’, and ‘Z’. The peculiar thing was the absence of the letter ‘O,’ and I found myself wondering why.

Given the nature of my application, I realized there could be any of the 3 alphabets in each position, leading to a total of 24³ possibilities, which equals 13824. The challenge was to assign a unique number to each combination, such as:

- ‘AAA’ → 0

- ‘AAC’ → 1

- …

- ‘ZZZ’ → 13823

In my quest for a solution, I delved into complex concepts like minimal perfect hashes and other convoluted approaches. Unfortunately, I got caught up in tunnel vision, overlooking the most straightforward solution. My thinking was so ingrained in base 2 and base 10 that I unintentionally restricted my perspective.

After a bit of self-reflection and a pep talk, I reminded myself that it’s okay not to have all the answers immediately. I needed to be more forgiving of my learning process.

And then, the breakthrough:

The key was to represent each alphabet with a number, where ‘A’ corresponds to 0 and ‘Z’ to 23. This allowed me to convert combinations like ‘AAA’ to 0, ‘AAB’ to 1, and so on, up to ‘ZZZ’ being represented as 13823.

In essence, the solution lay in using a base-24 counting system. Why this eluded me initially, I can’t say, but moving forward, I’ll keep this valuable lesson in mind—sometimes, the simplest answer is the most effective.

So, the takeaway is clear: don’t be too hard on yourself for not knowing everything instantly. Embrace the learning process, explore different perspectives, and you might just uncover a minimal perfect hash for your unique challenge!

Related Posts

Oops.. Waiting for the autor to whip up some cool related posts!