Hobbyist Competitive Programmer to Software Developer at HackerEarth

Prologue - Late December 2012, beginning of a new semester.

Reached college campus 2-3 days earlier only to know that we have planned to "mass bunk" the first week. Had no plans whatsoever for the 10 days that lied ahead. Took a stroll around the hostel and found a guy who, I speculated had already started studying for mid-semester exam. On later inspection I found that he was solving some mathematical puzzle on codechef.com. I had heard that name before but never bothered to browse around. He explained me that puzzle with sample input and asked me for output. It all started there, the craving for the green AC tick.

Open Diary Post: How I lead 4 years of Computer Engineering

Life is like a real-time strategy game. Its great to know beforehand how others played it when they were at your situation. In this short post, I'm summing up scenarios I faced, decisions I made and their outcomes during four years of Computer Engineering.

Install GIMP via Git - Getting Started Contributing to GIMP

You may be wondering why I should install GIMP via Git and go through all of the "trouble" when I have a short way out via apt-get or deb package or tar ball or many other ways depending on your OS or Linux distribution.

Well, one reason can be you want to use the latest update as soon as they're pushed in the repository. The other, more probable one, can be that you want to contribute to GIMP and are looking for a guide that helps you to compile and make GIMP from source, apart from the GIMP which you may already have.

This guide is tested on Ubuntu 14.04 32 bit, I can only hope it works on other distros of linux as well. :p

Tip-off: Use the most recent version of your distro or if you have LTS installed on your machine then make sure it is up-to-date.
Step 1:

Let's create a directory where we will store all the clones or tar balls. Fire up the terminal and run the following commands. (I'd recommend not to close the terminal session until the installation is done)

mkdir -p ~/sourcefiles
cd ~/sourcefiles

Graphic Designs for ACM NIT Surat

During pre-final year of Computer Engineering at NIT Surat, I took over the responsibility of graphics/poster design activities of ACM Chapter NIT Surat. Below follows my work and experience during their creation.

EPIPHANY! Online Coding Competition of SVNIT. This one's quite geeky actually. Solely based on idea generation. All I did is take a screenshot of my terminal window, added some spices and peppers from Iron Man, and final touch using idea of console based applications.

Programming Contest Poster

Orientation Programme poster for ACM Chapter - NIT Surat. Idea was to connect every single student irrespective of his/her branch. I used several human shapes and connected them with ACM logo. That's it! Implementation was a little tough though!

Dynamic Programming or Memoization : Simple optimizing Concept yet Effective

Dynamic Programming or Memoization is a well known technique for optimization.  It is just a method that remembers your previously calculated results and stores it somewhere so that when time comes you can use it again.

Just to begin with, a straightforward example of Memoization is calculation of Factorials. When we calculate Factorial of 5, i.e.

5! = 1*2*3*4*5 = 120

Now when you're asked to calculate Factorial of 6, a normal human being wouldn't go on like 1*2*3*4*5*6 rather he would think that "Well, I just calculated upto 5! why not simply multiply 6 to the answer of 5! " This is exactly what we are going to make our computers to do.

So, How do I make computer to remember pre-calculated results?
Answer is as simple as the question, just store them at a particular location in any array/list/vector.

Have a look at this simple Python implementation for memoized Factorial.

C/C++ and Python Program to find GCD of a list of numbers

A very easy question though, yet thought posting about it thinking it may improve my explanation prowess.

Lets get back to old school math, how did we find Greatest Common Divisor (GCD) or you may call it Highest Common Factor(HCF) of two numbers?

Assuming you know primary Maths, I'd proceed further.

Lets take an example before we go ahead.

Find GCD of 54 and 24.

Divisors of 54 are: 1, 2, 3, 6, 9, 18, 27, 54.

Divisors of 24 are: 1, 2, 3, 4, 6, 8, 12, 24.

Common divisors of 54 and 24: 1, 2, 3, 6

The greatest of these is 6.

Hence gcd(54,24) = 6

Okay, lets write an algorithm for this. Well, one would say, there's nothing to think of any algorithm, things are crystal clear. Find out the factors of two numbers, then find common factors and then the largest of them.

But brother! There exists a better algorithm. Our Father of Geometry, Euclid, left us an algorithm already. We simply have to implement it.

Fast Power Algorithm: C/C++ and Python Code

In competitive programming, traditional way to finding power may not work sometimes.

By traditional way I mean if we have to find 2^10 (just as an example).

Or else simply by using library function after including math.h (in C) we can do it by pow(2,10)

Well, but this doesn't help us anymore when it comes to finding base to the power (base^power) where power could be anything in the range 0 to 1000000 or even greater value, same goes for base

Whilst you may think it impractical but in competitive programming questions ask us find Modulus of the answer by any prime number such as 1000000007, just to make sure answer remains in range of int data type.

i.e. pow(2,100)%1000000007 = 976371285

Lets come to the point and discuss what you have come for :)

Fast Algorithm:

result = 1
If power is odd:
    result = result*value

value = value*value
power = power/2

Yeah, I know, above algorithm more looks like a code & was nothing but a bouncer. ;)