Thoughts of a programmer

Square Root Decomposition

Let’s consider the Problem Statement from HackerEarth. Basically, you are given an array of size and queries. Each query can be of two types - - add to the element of the array - print the odd number of the array if it exists, else print And all the indexes are -based. So how can we solve this problem. Let’s try brutefor... Read more

Python & Terminal

(Note: All of these is related to Python 2. Python 3 may show different results.) While doing some office work, I came across this. I had written below line in my Python 2 interpreter. >>> s = '©' >>> s #for checking the value of s Surprisingly, I got the following value. '\xc2\xa9' The reason I was surprised,... Read more

Life of a binary

Almost every one of you must have written a program, compiled it and then ran it to see the fruits of your hard labour. It feels good to finally see your program working, isn’t it? But to make all of this work, we have someone else to thankful too. And that is your compiler (of course, assuming that you are working in a compiled language,not an ... Read more

Threading Explained

Normally the programs that you write are single-threaded. By single-threaded, I mean that the processor starts at the first instruction in the program and then executes them one-by-one in the sequential manner, of course with some branching here and there, until eventually it reaches the last instruction in the program and the program ends. But... Read more

Python 3 and Unicode

If you don’t know what is Unicode, UTF-8 or UTF-16 or if need to refresh your memory on these topics, then before reading this article, check this one What everyone should know about Unicode. I have divided this article in two parts, one for Python 2 and one for Python 3, since there are some differences in how each handles string and unicode i... Read more