Friday, January 05, 2007

Stock Index

What does the stock Index indicate?

First, let’s look at what an index number represents. Although there are different ways to calculate index numbers, it is important to remember the numbers represent a change from an original or base value.

The number is not important. What is important is the percent change over time. This movement up or down gives you and idea of how the index is performing. Is the Dow up or down? The index is calculated “on the fly” during trading to give investors a sense of direction to the market it represents

The sensex's calculation involves dividing the total market capitalisation of 30 companies in the index by the index divisor — the only link to the original base period value of the sensex.

These 30 companies are taken as the representative of the Market. There may be more than 30 companies registered in the exchange.


Spell Checkers

Ever Wondered how search engines like Google, Yahoo or for instance Microsoft word Does spell checking.

Well the basic idea is to get Levenshtein or Damerau-levenshtein distance between the mis-spelled word and the other word. But do we find the distance with all the other words that are in the vocabulary. The answer is No. We reduce the subset of the words to checked. In the Search Engines it can be the most recent or the most used words and there are other techniques to do so.

Some insight into Google spell checking.
Spelling Suggestion at Wiki.

Tuesday, January 02, 2007

Casting Out Nines

How do you check the answer of a large multiplication like 8216*4215=36430440 without actually doing the multiplication.

Sum 8+2+1+6=17. Take modulo 9 = 8.
Sum 4+2+1+5=12. Take modulo 9 = 3.

Sum 3+6+4+3+4+4=24. Take modulo 9 = 6.

Now check 8*3=24 and 2+4 = 6.

Austrian Method of Subtraction

How do you subtract 5592 from 11149. Simple question....

There's an interesting method which involves only addition as it is easier to do than subtraction. Add from the amount to be subtracted upto the next higher unit, then to the next and so on.

Example 5592 + 8 = 5600. 5600 + 400 = 6000. 6000 + 5000 = 11000. 11000 + 149 = 11149.
so the answer is 8+400+5000+149 = 5557.

Pascal's Triangle

There's a very good article about Pascal's Triangle in Wiki. I am just enumerating some important points for quick reference.

- Construction of Triangle, value of the element is equal to the sum of the above two adjecent values.

- Sum of the elements of the mth row is equal to 2 raised to power m-1.

- Elements of mth row correspond to coefficients of 11 raised to power m-1.

- Generally the elements of mth row are the coefficients of the binomial expression (x+y) raised to power m-1.

- The diagonals next to the edge diagonals contain the natural numbers in order. Moving inwards, the next pair of diagonals contain the triangular numbers in order.

- Starting at the top 1, without backtracking or going sideways, try to get to another node via these grid paths as many ways as possible. The answer is whatever number the node has.

- Sum of a shallow diagonal is a Fibonacci's number.

- In rows where the second number (the 1st number following 1) is prime, all the terms in that row except the 1s are multiples of that prime.

- Pascal's triangle can be used as a lookup table for the number of arbitrarily dimensioned elements within a single arbitrarily dimensioned version of a triangle (known as a simplex).

- No one knows whether any number occurs 5 times in a Pascal's triangle.

Monday, January 01, 2007

Hats

There are 5 persons in a line, all facing in the same direction. There are 5 hats, 2 white and 3 black. A person can't see the color of his own hat, but can see the color of the hat of all the people standing in front of him.

The Third/middle person was asked to tell the color of his own hat. He couldn't answer. Then the second person( the person in front of the middle one) was asked the color of his own hat. He too couldn't answer. Tell the color of the Hat of the first person in the line?


===========================================

Solution:

Middle person couldn't tell the color. It means of the two persons standing in front of him at-least one of them was wearing a black hat.

Second person couldn't tell the Hat's color. He knows that there has to be at-least black hat either on him or on the first person. If the first person is wearing white then he is surely wearing black. But if the first person is wearing black, then he can't tell. Thus the first person is wearing black.

Salaries of three persons

There are 3 persons A,B,C and their salaries are X, Y, Z respectively.

Problem: Device a scheme so that all three of them know X+Y+Z, by asking each other questions.

Constraint: None should come to the other one's salary, i.e. A should not know Y and Z and so on...


===============================================

Solution:

C tells B that its salary is K (a fake value)
B tells A the total K+Y
A tells C the total K+Y+X
Finally C calculates X+Y+Z and tells it to everybody.