- better than friendfeed, just what I want

Experimenting with's Y! bot. You can post to the huge set of social networks supports - all using their integration with IMs, SMS and Web. Prety cool :)

Rope Escape

Rajeev is trapped atop a building 200m high. He has with him a rope 150m long.There is a hook at the top where he stands.

Looking down, he notices that midway between him and the ground, at a height of 100m, there is a ledge with another hook. In his pocket lies a Swiss knife.

How might he be able to come down using the rope, the two hooks and the Swiss knife?

Source :

[ALGO] Six Colored Balls

We have two red, two green and two yellow balls. For each color, one ball is heavy and the other is light. All heavy balls weigh the same. All light balls weigh the same. How many weighings on a beam balance are necessary to identify the three heavy balls?

Source :


I have a build which produces some extra files (not to be checked in).
Every time a do a build, svn shows these files as non versioned, new files and I have to ignore them.

Enter -
svn propset svn:ignore
. Here is how it worked for me :
prompt> svn status
? test.log
? test.log.1
..... (other src code)

Look at those test.log entries - my test case generated them and I'm least bothered to delete them. However, it corrupts my svn status output :-)

So will create an ignore file :
prompt> cat ifile

and ask svn to ignore these file patterns :

prompt> svn propset -R svn:ignore --file ifile .
prompt> svn status
M .
M src
M src/test
... (other src code)

There - the test.log entries no longer show up in svn status

prompt> svn commit

Detailed reading on svn property set :

Find if there is only one bit set in a number

In the bit representation of a number, find if there is exactly one bit that is set.

e.g. your approach should say true for the following numbers :
and false for the following numbers :

[PS] Catch the Fox

Consider five holes in a line. One of them is occupied by a fox. Each night, the fox moves to a neighboring hole, either to the left or to the right. Each morning, you get to inspect a hole of your choice. What strategy would ensure that the fox is eventually caught?

Algorithms from "100 Interview Questions for Software Developers" : Part 1

Q1. How do you find out if a number is a power of 2?
Q2. And how do you know if it is an odd number?

All purpose problem solving algorithm

LOL - Only if he had put in all that logic into solving the real problem ;-)

[ALGO] Water jugs problem

Suppose that you are given 'n' red and 'n' blue water jugs, all of different shapes and sizes. All red jugs hold different amounts of water, as do the blue ones. For every red jug, there is a blue jug that holds the same amount of water & vice versa.

How can you find the grouping of the jugs into pairs of red & blue jugs that hold the same amount of water, in the minimum number of comparisons.

Operations allowed
  1. always compare between a red and a blue jar (no two reds, no two blues)
  2. fill water in red / blue jug
  3. pour from red jug to blue (& vice versa). This will help compare the capacity of the jugs.
Source : Introduction to Algorithms (by Cormen..., Problem 8-4)

Find if number occurs exactly n/2 times in an array

You have an array of number/characters. If there is a number which occurs exactly n/2 times.
and all other elements in the set/array are distinct, can you find the the repeating number?

Expected time complexity : O(n)
Expected space complexity : O(1)

What if the other members are not distinct?
Can we solve the problem in O(log n) time complexity? (distinct and / or not distinct)

Source :

Dividing array into groups

Divide a list of numbers into groups of consecutive numbers but their original order should be preserved.


should be divided into two groups like this:
<2,4,1,0,3> <8,7,6>

Source :

Sort on second key when, first key in a set is sorted

Assume that we are given as input n pairs of items, where
  1. the first item is a number
  2. the second item is one of three colors (red, blue, or yellow).
Further, assume that the items are sorted by number. Give an O(n) algorithm to sort the items by color (all reds before all blues before all yellows) such that the numbers for identical colors stay sorted.

For example: (1,blue), (3,red), (4,blue), (6,yellow), (9,red) should become (3,red), (9,red), (1,blue), (4,blue), (6,yellow).

Find if summation of numbers from two lists is given number

Problem: Given two lists A & B define an algo, which will identify two numbers 'a' and 'b', such that a + b = x, where 'x' is the input.