Treasure

On my way back home from Boston on the Commuter rail, I noticed two high school students sitting across from me who were intensely focused on a piece of paper, which appeared to be a Karnaugh Map problem. They were discussing the number of possible outcomes for the problem, and I couldn't help but be intrigued. As I observed them, it triggered a vivid memory from my own school days when I had written an algorithm to auto-solve K-Maps. I remembered the sense of satisfaction and accomplishment that came from solving those types of problems, and it was exciting to see these students engaging with the same type of challenge. It made me wonder how many other young minds are out there exploring the exciting world of computer science and programming.

Ajmer, a small town in India, was quite isolated from the rest of the world during my schooling years. Computers were considered a luxury and obtaining an opportunity to use one was considered a privilege. Computer Science was a subject taught in school, and during our high school years, we had the option to choose a specific stream to study in depth for the next two years, preparing for competitive exams for college admissions. The Computer Science stream was highly coveted, with only the top 20% of students given the opportunity to select it. I was extremely eager to be a part of this branch and studied relentlessly to score high enough to be eligible. The joy and excitement I felt when I learned that I had exceeded the minimum required score and was able to opt for my dream branch are indescribable.

Our computer teacher's explanation of how computers work was fascinating. He explained that at the most fundamental level, computers only understand two states: "on" and "off," represented by the binary digits 1 and 0. He then introduced us to Boolean algebra, a mathematical system that deals with logic and truth values. We learned how Boolean expressions can be used to manipulate binary values and how these manipulations form the basis of all computer operations. The idea that complex computer programs can be broken down into simple operations using Boolean algebra was mind-blowing to me. It was like learning the secret behind a magic trick, and I knew then that I wanted to dive deeper into the world of computer science.

During my school days, the computer lab was a highly protected and sensitive place where even the slightest particle of dust was considered a potential threat to the computers. The lab was kept dimly lit to minimize the stress on the computer screens. As we entered the lab, we had to take off our shoes and wear the provided slippers to keep the lab as dust-free as possible. Inside the lab, there were about 10-15 computers, each displaying a black DOS prompt screen. Our school's computer curriculum included C++, but the school was still in the process of procuring a license for Turbo C++. So, while we waited, we were taught programming languages like Pascal, GW Basic, and software like WordStar (DOS-based word processor) and Lotus 1-2-3 (DOS-based spreadsheet software). Despite the limitations, those days were full of learning opportunities and have played a significant role in shaping my interest in the world of computers.

When I first learned about Truth tables, K-MAP, SOP, POS forms, I was fascinated by the idea of simplifying complex Boolean expressions. I was excited to see how the different techniques like Karnaugh Maps and Boolean algebra could simplify complex circuits and logic. This sparked my curiosity, and I decided to write my own version of an algorithm that could auto solve K-Maps, create truth tables, and generate all sorts of canonical forms. I spent countless hours researching and implementing the algorithm and was thrilled when it worked flawlessly. It was a significant achievement for me, and I felt proud of myself for being able to apply the concepts I had learned in a practical manner.

When I completed writing that program, I felt a sense of accomplishment and pride in my work. It took me almost a month to write the ~3000 lines of code, which I had written on a notebook with a pen/pencil. While working on it, I learned many things. I came to realize how difficult it is to manage a single monolithic program with hundreds of functions, and how important it is to follow the principles of classes and the single responsibility principle. Moreover, I understood the concept of integration and how crucial it is to design software components that work well together. Though I had a good understanding of these concepts, I had not yet heard any of these terms before I was almost in the middle of my engineering studies.

Up until that point, I had only tested the program manually by executing each line of code and recording the variable values in a table that I updated with every line. It was a slow and frustrating process, but I was determined to make it work. 

To run the code on a real computer, I needed access to one. But as I mentioned earlier, computers were a luxury at that time, and I did not have one at home. The only place where computers were available was our school's computer lab, but it posed several problems. The first issue was the limited time available. We had access to the lab only once a week for 30 minutes, during which we were supposed to complete the programming assignments given by our teacher. Although I tried to complete the assignments quickly to devote the remaining time to writing my own programs, it was not sufficient.

The second issue that added to my frustration was the fact that we couldn't use the same computer every time we had a computer lab session. Since the computers weren't networked, I couldn't access the code that I had written on a different machine in the previous session. I tried various ways to overcome this obstacle, including requesting to always use the same computer and even speaking to my teacher about it, but nothing seemed to work.

After completing my schooling in Ajmer, I had to appear for various competitive exams to secure admission into a college. Luckily, I got into a Computer Engineering college in Jaipur, a bigger and more advanced city than Ajmer. I was thrilled at the prospect of exploring the new labs and finally getting to write my Boolean Algebra program. However, my excitement was short-lived as I learned that the lab wasn't ready yet and would take several months to be fixed. To make matters worse, the first year of engineering in India is usually common for all branches, so nobody seemed to care much about the unavailability of the computer lab. 

The saying "Where there is a will there is a way" proved true for me.

Luckily, I met a new friend named Swami who had a computer at home. I discussed my situation with him, and we came up with a pact. I would help him with his major project, which was also a C++ program, in exchange for him allowing me to work on my program on his computer.

To clarify, having access to a computer and actually writing the program on it are two different things. In this case, I had to give my notebook with the source code to Swami and he would manually type it into his computer. After dedicating almost an hour daily to this task, he completed writing the program after 2-3 months. However, upon running it, we encountered a number of errors such as missing semicolons or misplaced double quotes. It took another month to fix all the syntax errors

I provided Swami with a sample input expression of A + A'B and anxiously awaited his return with the desired output of A + B. However, upon his return, he informed me that he had written exactly what I had asked for, and even though the output was not what I expected, I still had to complete his major project. In an effort to appease him, I offered to complete two projects for him if he would just tell me the output. He responded that the output was not A + B, but it was also not a significant issue since the actual result was B + A. He was not aware that Boolean expressions are commutative, and I was elated that it was functioning exactly as I had intended. We tested numerous other cases, and all of them worked flawlessly.

After Swami successfully compiled the program, the first test case he ran did not give the expected output of A + B. However, he pointed out that the output was B + A, which was a commutative form of the original expression. Though initially disappointed, the author soon realized that this output was still correct and jumped in excitement as the program worked flawlessly for all the test cases they tried.

That was the initial version of my "Boolean Algebra" program, and since then, I have written it for various platforms such as Visual C++, Win Forms, Silverlight, and Phone apps, and continue to update and improve it.

Today, I feel grateful to be able to work on an advanced version of "Boolean Algebra" while sitting at my desk surrounded by two laptops, a MacBook, two big monitors, an iPad, a droid tab, Alexa, Google Assistant and many other gadgets. Despite having access to all these modern technologies, I still find myself using the good old notebook with a pen or pencil to write code, just like I used to do in the past.

Comments

Popular posts from this blog

Delayed promotion is no promotion

The Car