DEV Community

Getting started with Competitive Programming - Build your algorithm skills

Avi Aryan on October 08, 2018

First posted on my email list I started Competitive Programming as soon as I got into college, around 2014. And I seriously continued with C...
Collapse
 
arten1337 profile image
Akhand Pratap Singh

why not python huh? what is the problem with python?
why do people hate python so much.

Collapse
 
aviaryan profile image
Avi Aryan

Python is not good for CP since it is slow.

It also has good support for very large numbers which encourages people to solve certain arithmetic related problems in the wrong way (you get TLE).

Python gives less control over the system memory it consumes (unlike c/cpp), a side-metric on which CP performance is measured.

Collapse
 
mayurvpatil profile image
Mayur Patil

There are many languages build for a specific purpose, Python is considered as high level language which come with many boiler plates which increases execution time(That couse TTL internally) and it is best for its simplicity and code readability.

In recent code Jam Qualification round I found the best python code, which contains less than 10 lines of code while for other submitions and you'll find plenty of code for the same solution. Check that out here... codingcompetitions.withgoogle.com/... (submitted this solution in 1 minute 53 sec)
[Note: This python guy have used CPP in next 2 submissions.]

Though, I agree with Avi after using python and Java.
Anyway, Language is just a syntax, CP is all about problem solving ,algorithms and competition.
So go ahead with any language.
CP is more harder than writing comments. Best of luck.

Thread Thread
 
aviaryan profile image
Avi Aryan

In recent code Jam Qualification round I found the best python code, which contains less than 10 lines of code while for other submitions and you'll find plenty of code for the same solution.

I have had the same experience in the past CodeJam.

Collapse
 
arten1337 profile image
Akhand Pratap Singh

Probably you don't use python then. Every Judge has a 5x multiplier for python. And yes you can also control the memory in python. Don't discourage people for using python.

Thread Thread
 
purohitkrishnar profile image
Krishna Purohit

Another main reason I think is that it has so much stuff built-in that when a newbie programmer learns python he doesn't need to understand concepts like how variables are stored in memory, which is important to understand in the case of languages like C/C++, now it may look like an advantage but all it does is makes us ignorant to the stuff which happens "under the hood". I don't think it has really to do with CP specifically, since many people learn C/C++/Java as their first language and hence use them for CP.

Collapse
 
aaryanpakhrani profile image
Aaryan Pakhrani

Did you know that you get more time in competitions if you use pyhton.

Thread Thread
 
aviaryan profile image
Avi Aryan

Yes. And that may help you solve certain problems easier than C.

But I personally find that the higher-level abstractions of Python get in the way when solving problems that can only be solved by using low-level concepts.

Collapse
 
amit9031jsr profile image
Amit Mandal

best book or tutorial to start with cpp in short time. I want to start cp.

Collapse
 
aviaryan profile image
Avi Aryan

This book cses.fi/book/book.pdf

(should be a legal copy, not sure)

Collapse
 
amit9031jsr profile image
Amit Mandal

I want c plus plus best book or tutorial. more practical concepts

Thread Thread
 
aviaryan profile image
Avi Aryan

This book has enough practical concepts. You don't need more than that. Speaking as an almost 6-star Codechef coder.

Collapse
 
kytes_of_stone profile image
Sourav

Any Similiar material for Java?

Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

Nice 👌

Collapse
 
muhs4lman profile image
muhs4lman

If I choose JavaScript what's gonna happen?

Collapse
 
garganshul108 profile image
Anshul Garg

A small article on solving trees from my side is here. Please check it out.