Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Thursday, December 27, 2012

comment_icon 2 Learn The ART of Programming

Programming is an Art of problem solving. All good programmers love the programming and they will do this passionately that’s why they became good programmer and mastered this art.
If you want to be a good programmer you need to give your 100% and you have to start thinking logically.
Things to be taken care before Solving a Problem:
1.       Read the problem carefully and try to understand what is all about and what should be the final outcome/solution.
2.       Don’t get tensed by thinking that problem is very tuff and I can’t solve it, be positive.
3.       Don’t Ever try to solve the problem in single shot do it step by step (if don’t know the solution or how to solve it).

Let’s give it a Hit

Problem : you need to draw the shape given below


Solution Approach:

If you see this problem carefully you can see that you have to draw the starts such that ,the number of starts in each line is 2n-1 i.e. (2*1-1=1,2*2-1=3..).
You also need to take care of space before the stars so it should form a pyramid.
So now you can see that problem is divided into two sections 
  1.  draw space
  2. draw star

        - - - *
        - - ***
        - *****
So this is the way you should solve the problems .
If still have doubts you can ask here. Feel free to drop your comments