Home Misc Some general tips for programming.

Some general tips for programming.

by nikoo28
0 comment 6 minutes read

A Programming Contest is a delightful playground for the exploration of intelligence of programmers. To start solving problems in contests, first of all, you have to fix your aim. Some contestants want to increase the number of problems solved by them and the other contestants want to solve less problems but with more efficiency. Choose any of the two categories and then start.

If you are a beginner, first try to find the easier problems.Try to solve them within short time. At first, you may need more and more time to solve even simple problems. But do not be pessimistic. It is for your lack of practice. A good programmer spends 10% time for coding and 45% time for thinking and the rest of the time for debugging. So to decrease the time for coding you should practice to solve easier problems first as they increase your programming ability.

1. Programming languages and dirty debugging

Most of the time a beginner faces this problem of deciding which programming language to be used to solve the problems. So, sometimes he uses such a programming language which he doesn’t know deeply. That is why; he debugs for finding the faults for hour after hour and at last can understand that his problem is not in the algorithm, rather it is in the code written in that particular language. To avoid this, try to learn only one programming language very deeply and then to explore other flexible programming languages. The most commonly used languages are C, C++, PASCAL and JAVA. Java is the least used programming language among the other languages. Avoid dirty debugging.

2. Avoid Compilation Errors

  • When you use a function check the help and see whether it is available in standard Form of the language. For example, do not use strrev() function of <string.h> header file of C and C++ as it is not ANSI C, C++ standard. You should make the function manually if you need it. Code manually or avoid those functions.
  • Don′t use input and output file for your program. Take all the inputs for standard input and write all the outputs on standard output (normally on the console window).
  • Do not use <conio.h> header file in C or C++ as it is not available in standard C and C++. Usually don′t use any functions available in header file. It is the great cause of compilation error for the programmers that use Turbo C++ type compiler. Using Turbo C++ type compiler should be avoided every time.
  • Built-in functions and packages are not allowed for using in online judge.

3. Forget Efficiency and start solving easier problems

Sometimes, you may notice that many programmers solved many problems but they made very few submissions (they are geniuses!). At first, you may think that I should try to solve the problems as less try as possible. So, after solving a problem, you will not want to try it again with other algorithm (may be far far better than the previous algorithm you used to solve that problem) to update your rank in the rank lists. But my opinion is that if you think so you are in a wrong track. You should try other ways as in that and only that way you can know that which of the algorithms is better.
Again in that way you will be able to know about various errors than can occur. If you don′t submit, you can′t know it. Perhaps a problem that you solved may be solved with less time in other way. So, my opinion is to try all the ways you know. In a word, if you are a beginner forget about efficiency.

4. Study Algorithms

An algorithm is a definite way to solve a particular problem. If you are now skilled in coding and solving easier problems, read the books of algorithms next. Of course, you should have a very good mathematical skill to understand various algorithms. Otherwise, there is no other way but just to skip the topics of the books. If you have skill in math, read the algorithms one by one, try to understand. After understanding the algorithms, try to write it in the programming language you have learnt. If you can write it without any errors, try to find the problems related to the algorithm, try to solve them.

Remember – Practice makes a man perfect.

Some links to online problem solving portals are:-
http://www.spoj.com
https://leetcode.com/
http://www.codechef.com
http://www.projecteuler.net
http://www.topcoder.com

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More