Evolution of programming methodology

February 8th, 2010

From assembly language in 1990 to C# in 2005, the Microsoft has brought a lot of programming languages to the developers. One reason of its growth is due to various programming methodologies evolved in the past. Here are some of them:

  1. Sequential Programming.
  2. Structured Programming.
  3. Object Oriented Programming.
  4. Interface Based Programming.
  5. Language Integrated Query Programming, called LINQ.
  6. Declarative or Attribute Programming.

Tennis Puzzles

February 7th, 2010

Qn . “There’s a tennis tournament with one hundred twenty-seven players, Shockley began, in measured tones. You’ve got one hundred twenty-six people paired off in sixty-three matches, plus one unpaired player as a bye. In the next round, there are sixty-four players and thirty-two matches. How many matches, total, does it take to determine a winner?”

Ans.  This puzzle requires little math. Look at the second question, and come back to this to solve it fast.

  1. 126 players 63 matches
  2. 64 players 32 matches
  3. 32 players 16 matches
  4. 16 players 8 matches
  5. 8 players 4 matches
  6. 4 players 2 matches
  7. 2 players 1 match
  8. 1 player 0 match

Adding all the matches total to 126. The Bye player should not be considered because the total players are always 126.

Qn. There are 36 players in a single elimination tournament. How many matches to be played to determine the winner?

Ans. Two players require one match to determine the winner. So, 36 players require 35 matches to determine the winner. There is another math to figure this out. Thirty five players have to lose to decide the winner. So, there are thirty five matches.

Redirecting a website to a different website

February 6th, 2010

Just like anyone asks the local post office to forward the letters when they move is applicable to websites also. As an example our table tennis store e-commerce site was hosted in a dot net nuke platform in 2008. The site was called Table Tennis Network. In 2009, it was moved to a high end e-commerce platform and to a new domain TableTennisStore.US. This is where we had to use 301 redirects to redirect the old website to the new one.

There are few ways you can redirect your old site to the new one:

1. Using a .htaccess file at the root of the site, the old site can be redirected to a new web site.

2. Using URL re-write settings in the web.config file, the re-direction is possible.

3. By manipulating the header section of the default page, it is possible to re-direct.

Here is a piece of code in vb-script to do this trick:

<%@ language=”VBScript” %><%
‘ Permanent redirection
Response.Status = “301 Moved Permanently”
Response.AddHeader “Location”, “http://www.tabletennisstore.us”
Response.End
%>

The above code will redirect the site where it has the default.aspx file to a new website http://www.tabletennisstore.us.

Microsoft’s Billiard puzzle

February 5th, 2010

Qn. “Suppose you had eight apparently identical billiard balls, but one of the eight is slightly heavier than the others. The only tool you have to measure is a balance scale. What’s the fewest number of times you’d have to use the scale to find the heavier ball?”

 Ans. Read the puzzle carefully. The puzzle did not say the eight billiard balls are of different weight. It says only one ball is slightly heavier. Comparing one ball to other is not efficient. You will use the scale too many times in that case.

The solution to this problem is by using the “divine and conquer” logic. Divide the 8 balls into three groups. The first group A have 3 balls. The second group B has three balls. The third group C has two balls.

(1) Use the scale once to compare the group A and B.

(2) If the group A weighs heavier than group B, take the group A into consideration. Ignore group B. Take any two balls in the group A and compare each other on the scale. If they are the same, the third ball in the group A is heavier. You don’t have to weigh the third ball to figure this out. If they are different, one of them is heavier. So, you have used the scale only twice to find the heavier – scale is used once in the step 1 and the second time in the step 2.

(3)  Now consider, the groups A and B weigh the same from the step 1. This brings the conclusion that they both don’t have the heavier ball. Take the group C, compare two balls to find the heavier. So, you have used the scale only twice to find the heavier – scale is used once in the step 1 and the second time in the step 3.

In just two steps and using the scale twice, you can find the heavier ball.

Water, Vessel puzzle

February 4th, 2010

Qn. “A mother sent her boy to the river and told him to bring back exactly 7 pints of water. She gave him a 3-pint vessel and a 5-pint vessel. Show me how the boy can measure out exactly 7 pints of water, using nothing but these two vessels and not guessing at the amount. You should begin by filling the 5-pint vessel first. Remember, you have a 3-pint vessel and a 5-pint vessel and you must bring back exactly 7 pints.”

Ans. Fill the 5-pint vessel first. Pour the water into the 3-pint vessel. This leaves the first vessel with 2-pint of water. Pour the water in the 3-pint vessel back into the river. Pour the 2 pints of water from the first vessel into the second vessel. Now fill-in the first vessel fully. This will make the first vessel with 5 pints of water and the second vessel with 2 pints of water. Thus the solution.