Programming Tutorial Blog - Code Gyan

Hi,
I’ve started a blog where I write posts regularly on topics which are difficult to understand and have limited resources online. You may follow the blog here . All topics are discussed with problems from spoj, codechef and codeforces. Currently, it has posts on topics like ‘Inclusion-Exclusion principle’ , ‘Square-Root decompostion’, ‘Sieves’ etc. Please feel free to share/comment/ contribute. Any suggestion/constructive criticism is appreciated!.

Edit : Added new post to help readers get started with problem solving using segment trees.

3 Likes

Can you post one on problems related to bits and bit manipulation?

Ya, I’ll be adding more topics in future.

For bitwise operations and some hacks on bits , you can refer to

https://graphics.stanford.edu/~seander/bithacks.html

It contains everything, even more, that what is required in competitive programming. Illustrations and examples are also available with each part along with optimisations, if required.

Also, C++ supports some inbuilt functions for the same:

__builtin _popcount(x), __builtin _popcountll(x) : Find the number of bits set in x.

__builtin _clz(x) : find the index of first bit set from left size, (Thus “31 - __builtin _clz(x)” can be used to find the value of floor(log2(x)) in a more efficient method)

1 Like

Nice blog for beginners.

Thanks for it.

1 Like

You have recently put up a code that is being used in the on-going Sept Long Challenge. You should have waited for the contest to end before uploading that.

I didn’t do it intentionally. However, it’s a very small part of the problem and long challenges are supposed to be ‘learn and solve’ contest.