Competitive programming is a sport of the mind in which you compete with others to code solutions to sets of problems as quickly as possible. The problems often involve math, logic, data structures, and algorithms. The programs are judged on a variety of factors including how quickly the program can run and how much memory it takes up.
Intrigued, I decided to give it a try on HackerRank, a website which has hundreds of coding puzzles and also hosts competitive programming competitions. In my AP Computer Science class, we get assigned lots of coding puzzles and I always found myself doing extra problems just for fun during my free time. I was hooked on the satisfaction of solving puzzle after puzzle, but I had never thought about doing it with speed in mind. Needless to say, I was quite horrible when I was first starting out. My typing was sloppy and I made countless careless errors from trying to think too fast. Even though I was the slowest one by far, I was still having a lot of fun just solving the puzzles without thinking about time.
Another aspect of competitive programming that took some getting used to was making my code as efficient as possible. With my previous coding projects, I’ve always assumed that if the code runs it’s fine without any thought about how long the code took to compile or how much memory was being taken up. I remember being surprised when my code gave the right results but was marked wrong because it took too long to compile. Through this, I’ve become more conscious about making my code as concise and efficient as possible.
Besides being fun, it’s also great practice for improving your coding skills and helping you prep for potential coding interviews. While doing some practice free response questions for my AP Computer Science exam, I came across a problem very similar to one I had done on HackerRank. The more problems you get exposed to, the better your problem solving will become. While I started out on HackerRank, there are many different websites you can use to start out. For those interested, here is the link: https://www.hackerrank.com/. There are also lots of competitions held by big companies such as Facebook and Google. To those looking for a coding hobby outside of robotics, I highly recommend giving competitive programming a try.