Getting to know me

My First Set of Open-Source Contributions

On October 10th, 2024, the NIE IEEE Student Branch (NISB) held a workshop on open-source contributions because Hacktoberfest had started. For those who don’t know, Hacktoberfest is a month-long celebration of open-source contributions that rewards you for participating, more on it in the end. During the workshop, they covered version control, GitHub, how to clone repositories, make changes, and submit a pull request (PR).

Open-source contributions have always amazed me—the idea of making changes to something that is visible worldwide is incredible. This workshop ignited a spark in me; I was filled with curiosity. I was very excited, and though it was a 2-day workshop, I had to go home on the morning of the second day. I tried to gather as much information as possible about what I missed, and the next morning, I left for Bengaluru.

The first thing I did after greeting my parents was to open my laptop and install Git Bash. When I read the documentation on how to clone a repo, Bash was frequently mentioned. Bash has a steep learning curve, but I managed to grasp the basics and cloned the repository created by NISB called Code-Alchemy to my PC. I started adding solutions—simple ones like linear search and insertion sort in Java. The files were initially in C++, but my seniors assured me it was okay to submit the solutions in any language, so I used Java. Using Bash, I submitted a pull request.

However, one bad habit I picked up from LeetCode was forgetting to convert arrays to strings. When you return an array from a function, it returns the memory address, and excited as I was, I didn’t check the output before creating and sending the PR. Not long after, the head of the repo pointed out the mistake in my code. I had to close the PR, add Arrays.toString(), and create the PR again. I can’t put into words how happy I was when I received the email saying my code had been accepted! At that point, my only goal was to successfully merge 4 PRs.

With this excitement, I opened the email and received a sticker from Holopin, a platform that issues stickers for Hacktoberfest. I didn’t know what to do with it, but it was cool. I then started checking out other repositories with the Hacktoberfest tag, but I didn’t find anything that matched my skill level. That’s when I returned to Code-Alchemy and found two more problems similar to ones I had solved on LeetCode. One required returning the first unique character, which I solved using LinkedHashMap, and the other involved shifting a given number of elements from the end of an array to the beginning.

By this time, I had discovered GitHub Desktop—a real lifesaver! It made my workflow much easier. I could clone repositories, open them in VS Code, edit the files, and make commits all in one place. I started using GitHub Desktop for the remaining 3 PRs.

The next PR involved a problem that almost made me pull my hair out. I had to reverse the order of words in a sentence, but the words themselves needed to remain intact. Determined to solve it, I delved into Java’s documentation and found two string functions: trim() and split(). After some trial and error, I decided to use split(), which takes a character as an argument and splits the string into an array of words. After obtaining the array of words separated by whitespace, reversing the array was straightforward.

The following problems involved binary search algorithms. The first problem I tackled was unrelated to binary search—it required eliminating duplicate data blocks and sorting them. I used an ArrayList because with a regular array, it’s difficult to know the final size. I applied insertion sort to the array before populating the ArrayList, and then returned the sorted array of unique elements.

The next problem was to find a target memory address among a list of addresses using binary search, which was simple enough. However, the final problem was quite challenging. I had to return the indices of broken nodes from a list of network nodes. I iterated through the list of broken nodes, used binary search to find their indices, added the indices to an ArrayList, and finally returned the indices as an array.

With that, I completed Hacktoberfest! To officially finish, your pull requests must remain merged for a week, so I had to wait until October 21st, 2024, to write this blog. Below, I’ll attach links to my Hacktoberfest profile, my Holopin profile, and my pull requests to Code-Alchemy.

I hope you enjoyed reading this blog! Have a great life ahead. Until next time, goodbye!


Useful links