## Find pairs of numbers in an array with difference ‘k’

The problem statement is, an long array is given with n elements, we need to find all the pairs of numbers in this long array which have a constant difference k. I will post three methods. The first method is the brute force method and has a runtime complexity O (n2), the next method has runtime complexity O (n*log (n)), and the last one will have the runtime complexity O (n).

## Jumble word solver again

I have already posted a jumbled word solver written in C language, although what I posted is actually become old, as I have changed some of the things in the code. I will update the post with this (hope to update!) with the new changes, but before it I would like to post the the same stuff in other languages and with different datastructure. Recently I am learning Perl and brushing up C++, therefore I will post jumble word solver written in C++ and Perl in this post.

Posted in Coding Discussions, Computer Science | | 3 Comments

## Commented!

I couldn’t stop myself from posting this from xkcd, this one is extreme :D

Commented!

Posted in Humor | Tagged | 2 Comments

## Check if a string is rotation of another

There are two strings. We need to find if one string is a rotation of the other. If yes then how many places it was rotated. The solution is pretty straightforward. I will describe two ways in this post. Continue reading

## Add vertical scrollbar in wordpress.com sourcecode blocks

Sometimes I post sourcecode accompanying my posts which are long and makes the length of the post unnecessarily long. The wordpress.com sourcecode shortcode has an option collapse which you can make “true” to collapse the sourcecode box when the page loads. If you post a long code, when the code box is expanded it will be inconvenient to scroll through the page and read. Also sometimes you might not want to collapse the codebox when the page loads. For this I have a solution. Add vertical bars to the codebox using the div tags.
In this way the length of the code portion in the page remains fixed and to read the code one requires just to scroll in the code box. Checkout what I am talking about in some of the code posts, for example in the posts here and here. Here is how it is done. Continue reading

Posted in GNU+Linux+FOSS, Tutorials | Tagged , , | 1 Comment

## Implement queue using stack

The puzzle is to implement basic queue operations with using only basic stack operations. That is, a stack object is given, we need construct a wrapper for the queue functions, insert, remove, which will only use the stack object as its storage, and naturally will have to use the stack operations. I have already posted the opposite task in the post Implement stack using a queue

This can be done using two stack objects. We call these the first stack and the second stack. Although either the insert or the remove complexity will no more be O(1).

I have discussed the process gradually. I added the last solution when it clicked in my mind while reviewing this post.

Posted in Coding Discussions, Computer Science | Tagged , , , | 4 Comments

## Get list of installed packages and their details in R

When we need packages in R we install them. May be some time you wanted to have a look what packages were installed in your system and also what there version numbers are. Although rarely you would like to do this, here is a small tip on how to do it. Continue reading

## Plot histogram in terminal

We had assignments to print “*”s in different formation in undergraduate class, which I never liked as they were pointless. Now I got a somewhat justifiable application, plot histogram in terminal. In the last post Generating random numbers from Normal distribution in C I posted the C code to generate random numbers from the Normal distribution using the Polar method. In this post I am posting a simple code to plot the histogram of generated random numbers from this or any other distribution. Let me first post the code and then explain what is going on. Continue reading

Posted in Coding Discussions, Computer Science | | 3 Comments

## Generating random numbers from Normal distribution in C

I needed to write a random number generator in C which will generate random numbers from Normal Distribution (Gaussian Distribution). Without this component I couldn’t proceed to finish writing a C code for Heuristic Kalman Algorithm by Lyonnet and Toscano for some experiments. I selected the Marsaglia and Bray method also known as the Polar method to generate Normal random variables. Here is how it is done. Continue reading

Posted in Coding Discussions, Computer Science | | 5 Comments

## C LANGUAGE UERS! Y U NO SEE STANDARDS!

C LANGUAGE USERS!
Y U NO SEE STANDARDS!

I had to make this. There are people who give a damn to the standards and follow the stone age Turbo C 3.1 compiler, run programs compiled by it. In the cases for compiler dependent and undefined behaviours, they try to guess in some way why the output was like that and get into a conclusion. Continue reading