Competitive Programming: A Mental Sport

Edited by Nalli Sai Soumya | Design by Ramana

“The best part of the competition is that through it we discover what we are capable of – and how much more we can actually do than we ever believed possible.” – anonymous 

It’s 7.50 PM. After quickly finishing dinner without actually savoring it, I return to my room and hurriedly start my laptop. I glance at the Wi-Fi icon at the bottom right corner of the screen, to make sure that the connection is up and running. I open up the Chrome browser, hit the Codeforces icon on the bookmarks bar, log in with my credentials and go to the Div-3 contest page for which I had registered two days ago. I open up the VS Code editor and jump back to the contest page, just seconds left for the contest to begin, my heart beating to the tunes of both excitement and anxiousness. 3…2…1… the battle begins!
The 2-hours that follow are a roller coaster of emotions: the anticipation that starts building up when we read the problem statement to the joy when we see our solutions accepted, dejection when our answer is rejected to the anxiousness that follows it when we try the problem again. Many Competitive Programming (CP) practitioners can relate to the above anecdote to some extent, especially when they are attempting a two to three-hour-long contest on the Codeforces or CodeChef platform. Picture each question as a boxing opponent for our brains to spar with! After 2-hours of the contest, although we feel drained, there is the satisfaction that we get from fighting a battle and coming out of it with novel learnings and experiences.

What is CP? 

Competitive Programming, CP for short, is a branch of programming where people test their problem-solving and coding skills by solving a given set of problems under a stipulated amount of time. Problems can be as easy as checking whether the given number is even, finding the largest perfect square smaller than the given number, or can be highly complicated requiring you to use some predefined algorithm or an existing aptitude/game/probability theory. Each problem will have some test cases given by the platform, which are used to validate the solution before finally submitting it. 

Ranging from Short 2-hour contests to Week Long contests, it makes people showcase their logical aptitude and how best they can convert their ideas to crisp and efficient algorithms. Generally, competitors are divided into 3-4 groups (like Div1, Div2) based on their rating, and they are made to compete within that group. Upgradation of level generally follows after giving a lot of contests.

The players are generally given 6-7 problems to solve on average. The problems themselves vary greatly in their intricacy, with difficulty generally higher for the later ones. The trick mainly lies in thinking of an efficient algorithm that is able to solve the problem within a given time bound. Although problems can have an easy solution (using ‘brute force’), it generally takes a significant amount of time (by the computer)  to compute the output, hence it is typically disapproved by the platform. Solutions are accepted if they give the correct output for all open and hidden test cases and the time required to run the code lies within the given time limit bound. Countless classic algorithms are available to tackle specific sets of problems like the Dijkstra algorithm and the Ford-Fulkerson algorithm which although greedy at heart are able to solve the problem efficiently.

Finally, the winner of a contest is the person who solves the maximum number of problems in the minimum amount of time.

Some crunchy data (from insti) to bite for motivation

Before we move ahead and fathom the embarkment of the CP journey, let’s first get motivated by some numbers and data which highlight the rise of CP culture in insti.

A significant chunk of insti students had their first taste of the culture during the Summer Programming Camp (SPC) organized by the Programming club last summer. The camp saw a whopping 600 registrations with 150+ people graduating successfully from the camp. As part of the SPC, the club conducted 4 contests with around 200 participants in each contest.

Later, Vineet Dhandharia, an ex-PC head, took the initiative to start a YouTube channel named ‘Programming Club IITM’, to release editorials for some contests. Apart from this, PC also conducted Shaastra Juniors CP Workshop and a Quarantine Contest.

How to embark upon the CP journey?

“At the end of my first year, I wasn’t confident in programming; in fact, I was quite scared of coding. A factory senior of mine made a small group and introduced me to CP. He made us do around 40 problems over a span of 2 weeks. I’ve always loved tackling logical problems and solving mind puzzles. Using programming to do them made me believe I could finally get rid of this fear of coding. That’s how my extraordinary CP journey began”, recalls Vineet Dhandharia.

“After brushing through the basic syntax of C++ programming language, I started solving random problems on Codeforces and gave a large number of contests. People think that they should first ‘learn’ CP and then solve problems, but I don’t think there is anything to ‘learn’ in CP, there are just problems and the things you learn from them. I always solved problems and learned things along the way, looking up things on the internet whenever I got stuck. The love of solving logical problems kept me always motivated and stuck to CP.”

“A few months into CP, I was informed by my seniors that CP actually helps in tackling coding interviews and tests for placements and internships (mainly for software firms). Knowing that something I did out of sheer fun could play a major role in deciding my future career made me give even more contests. I also set some small goals for myself and achieved them steadily.”

One of the current PC heads, Aditya C also took us through his journey, “Vineet first created a group among CS20B students and introduced us to CP. My friends played a major role in my journey, they gave me the motivation to learn new things and improve myself along the way.” Vineet also stressed the bonanza of motivation, discipline and knowledge that comes with friends. Aditya also adds, “CP was just a joy initially. As I solved more problems, I learned new approaches and concepts through the internet or through discussions with friends. As a result, I progressed automatically.”

The rise of the CP culture in insti

Around two years ago, there were very few people who knew about CP and practiced it. That number has increased substantially thanks to the initiatives taken up by The Programming Club (PC) last year.

Regarding the initiatives, Vinit tells us, “I always felt that had I been introduced to CP earlier, I could have progressed better. I felt that whoever steps into IIT Madras should be introduced to CP as early as possible so that they don’t feel the same regret. So at the end of my third semester, I made a group among CS20B students and introduced them to CP. Many of them were enthusiastic and started doing it with zest. Some of them, the ones filled with infinite enthu, also joined The Programming Club as coordinators (there were some non-CS people as well) making my original vision come true. After a decent amount of planning and preparation, we conducted ‘Summer Programming Camp’ for the whole institute, to propagate the sport of CP far and wide.” This was a major event that helped flourish the cp culture in insti!

The Past, the Present and the Future

After the camp, interest groups were formed on WhatsApp where ‘reminders for contests’, ‘information about various competitions’ etc. were shared. Exchange of ideas among practitioners also took place in these groups.

In mid-October, a new initiative called ‘Weekend Programming Sessions’ was launched. It involved splitting the insti junta into 3 groups: G0, G1 and G2 based on the expertise they had in CP. The club recruited new volunteers who took sessions explaining different data structures and algorithms used in CP. They also shared ‘Problem Sets’, which contained questions related to the topic taught. Few contests like the Quarantine contest were conducted with a dual aim – to let the students apply the concepts taught in the sessions and to impart that competitive experience among them. However, due to the confusion potpourri among the students regarding reopening and settling into ‘college life’, the initiative wasn’t carried on further.

“But we have similar ways to keep the culture thriving”, said Aditya. “Apart from conducting another ‘Summer Camp’ and revamping the ‘Weekend Programming Sessions’, we will create a mailing group which will send mails regarding major CP contests and other coding contests like CodeJam and Kickstart. We will conduct many contests and put out their Editorials, as I feel the best way to keep the culture lively is by allowing insti junta to give more contests and teach them along the way.”

Misconceptions and Truth

Now let’s clarify some misconceptions regarding CP that students have before they plunge into it. Firstly, CP is quite different from DSA. Vineet points out, “ DSA is basically a well-defined structure of concepts and respective set of problems, whereas CP is more general and has problem-solving at its core. People generally mix them up because they have quite a lot of things in common.  DSA teaches programming concepts over a well-defined set of problems, whereas CP is more diverse and novel at each step. It’s just that if you do CP, you will be more comfortable learning and grasping DSA. Also one can do CP persistently than DSA because CP has that ‘competitive’ factor over it, which makes it more exciting.”

“Many people do CP for the sake of placements and internships, it’s quite understandable. However, if you have only 3 months left for internship season/placements, DSA from websites like GeeksforGeeks and practice problems on Leetcode would serve you better. If you have a year with you for internship season/placements, then do CP in a persistent manner. However, in the long run, to continue with CP your inner motivation and love for problem-solving are important.”

Next, many students fret over which platform to give contests on. “Both Codeforces and CodeChef are good platforms to give contests”,  says Vineet. However, Aditya believes that “CodeChef would be a better option among newbies who are just starting CP as it hosts a large number of contests and they are relatively easy. Codeforces contests are quite difficult. As people generally get demotivated when they can’t give contests successfully, a bit of general advice would be to start CP on CodeChef and later move on to Codeforces.”

The Other Side of the Story

It is often observed that at some point in time people (especially non-CS people) stop doing CP, due to a lack of motivation, lack of programming peers or a hectic semester load. Some people discontinue it because they don’t find it worth the effort in the long run, and pursue some other interests (like exploring ML/DL). The following are a few experiences highlighting the reasons that impose irregularities in CP journeys.

“The contest timings are not preferable, and since this is a highly competitive domain, it is highly demotivating when we don’t perform well” and “The reason I was doing CP less frequently some time ago was that I was alone and a friend of mine also kind of stopped doing it around that time. I didn’t know what exactly to do and my rating stagnated,” these were some experiences shared with us. Furthermore, a NavArch student tells us, “For about 3 months of semester 4, I was out of touch with CP because of academics and other commitments during the hectic semester. Once you stop CP for a long time, it becomes a little tough to get back in momentum.”

Finally, a CS student recalls that “My experience in CP was quite short. I started CP like all others in my branch did, but with the way I felt it imposed upon me, I lost traction and left it as a whole. CP contests are thrice a week, usually at night, so giving it on a regular basis isn’t feasible when you are at home. And seeing others give various contests made the situation overwhelming.”

All this then boils down to how strongly you are interested in tackling logical problems and setting your priorities accordingly to do CP regularly, how meticulous you are in choosing the people you surround yourself with, and your time management tactics – which for me personally, was a long-lost battle. 

After looking at these conflicting (and somewhat confusing) opinions in the article, you might ask yourself, “How much should we do CP in order to secure jobs?” or “Is CP everything when it comes to programming, or are there other means to pursue my interests?”

Dhruv Maroo, a CP enthusiast answers both questions. He says,  “Tests and interviews conducted by different software companies are more CP oriented in the sense that they test your problem-solving skills. It’s the only ‘filtering strategy’ which companies can use to shortlist students.” He believes, “The most important thing is not to lose yourself completely into CP. I agree it’s quite addictive with its ranking system and quick evaluation, but it does not impart to you any ‘useful industrial’ skill like making a website or a version control system. It’s mostly about finding an efficient algorithm to solve a problem. Hence my suggestion would be to do CP only if you really love it and learn other useful skills side by side. If you find yourself not interested in CP after a while, do it to some appreciable extent so that it can help you crack your coding tests and interviews.”

Asking about the impact of CP in getting jobs, a student tells us, “If one is inclined towards technical roles for internship/placements, they should definitely give a shot to trying CP for about a month and continue or discontinue based on their interest. Being skilled in solving algorithmic problems might also prove to be beneficial in internship/placement selections in relevant roles. For branches that do not have CS-related courses, CP can provide relevant exposure to procure jobs.” A CS student further pointed out, “For people who don’t study CS books, CP is one of the main sources of continuous programming experience, also it is a very good opportunity for them to see how well they have improved in programming. This can help them in getting good software jobs.”

In a nutshell, treat CP like a sport; do it for fun and for that ‘competitive’ experience. If you feel uncomfortable and anxious in that environment, limit the scope of CP such that it overlaps with the DSA problems and helps you ace your coding tests. However, in my opinion, if you really have an enthusiasm for problem-solving and logical aptitude, you should pick up CP and do it just for its own sake, because what finally matters is your satisfaction and contentment.

Special Thanks to Vinit Dhandharia (Ex-PC Head), Aditya C (Current-PC Head), Dhruv Maroo, Aditya Sharma (for proofreading) and others who shared their insightful experiences!

Write a Comment

Your email address will not be published. Required fields are marked *