## Farmer Brown

Farmer Brown came to town with some watermelons. He sold half of them plus half a melon and found that he had one whole melon left. How many melons did he take to town?

Easy, three melons.

Farmer Brown came to town with some watermelons. He sold half of them plus half a melon and found that he had one whole melon left. How many melons did he take to town?

Easy, three melons.

Sam has got three daughters. The eldest daughter is the most honest girl in the universe and she always speaks truth. The middle daughter is a modest woman. She speaks truth and lies according to the situations. The youngest one never speaks truth. Not a single word she spoke was true and would never be true.
Sam brought a marriage proposal for one of his girls. It was John. John wanted to marry either the eldest or the youngest daughter of Sam as he can easily identify whether the girl speaks truth or lie!
John told his desire to Sam. However, Sam laid a condition. He told John that he will not say who the eldest, middle or youngest one is. Also, he allowed John to ask only one question to identify the eldest or youngest so he can marry one.
John asked one question and found the right girl. What was the question and whom should he pick?

The question he asked is, 'Is she older than her?'
He asks this question to one of the daughters.
If he asked this question to older daughter pointing at other two, he probably would know the youngest one! NO matter, she always speaks truth.
If he asked the question to middle one, probably he can choose either.
If he asked the youngest one, she always lies and he can find eldest one. No matter, he has to choose the youngest one based on the answer.

Three people check into a hotel. They pay $30 to the manager and go to their room. The manager finds out that the room rate is $25 and gives $5 to the bellboy to return. On the way to the room, the bellboy reasons that $5 would be difficult to share among three people, so he pockets $2 and gives $1 to each person. Now, each person paid $10 and got back $1. So they paid $9 each, totalling $27. The bellboy has $2, totalling $29. )
Where is the remaining dollar?

Each person paid $9, totalling $27.
The manager has $25 and the bellboy has $2.
The bellboy's $2 should be added to the manager's $25 or substracted from the tenant's $27, not added to the tenants' $27.

In a jungle where there is no streets lights or any other artificial source of lights, I notice a black snake crossing the road.
How did I get sight of snake ?

It's a day time.

A man hijacks an aeroplane transporting both passengers and valuable cargo. After taking the cargo, the man demands two parachutes, puts one of them on, and jumps, leaving the other behind. Why did he want two?

If the officials thought he was jumping with a hostage, they would never risk giving him a faulty parachute.

Two words are anagrams if and only if they contain the exact same letters with the exact same frequency (for example, "name" and "mean" are anagrams, but "red" and "deer" are not).
Given two strings S1 and S2, which each only contain the lowercase letters a through z, write a program to determine if S1 and S2 are anagrams. The program must have a running time of O(n + m), where n and m are the lengths of S1 and S2, respectively, and it must have O(1) (constant) space usage.

First create an array A of length 26, representing the counts of each letter of the alphabet, with each value initialized to 0. Iterate through each character in S1 and add 1 to the corresponding entry in A. Once this iteration is complete, A will contain the counts for the letters in S1. Then, iterate through each character in S2, and subtract 1 from each corresponding entry in A. Now, if the each entry in A is 0, then S1 and S2 are anagrams; otherwise, S1 and S2 aren't anagrams.
Here is pseudocode for the procedure that was described:
def areAnagrams(S1, S2)
A = new Array(26)
A.initializeValues(0)
for each character in S1
arrayIndex = mapCharacterToNumber(character) //maps "a" to 0, "b" to 1, "c" to 2, etc...
A[arrayIndex] += 1
end
for each character in S2
arrayIndex = mapCharacterToNumber(character)
A[arrayIndex] -= 1
end
for (i = 0; i < 26; i++)
if A[i] != 0
return false
end
end
return true
end

A train leaves from Halifax, Nova Scotia heading towards Vancouver, British Columbia at 120 km/h. Three hours later, a train leaves Vancouver heading towards Halifax at 180 km/h. Assume there's exactly 6000 kilometers between Vancouver and Halifax. When they meet, which train is closer to Halifax?

Both trains would be at the same spot when they meet therefore they are both equally close to Halifax.

Emperor Akbar once ruled over India. He was a wise and intelligent ruler; and he had in his court the Nine Gems, his nine advisors, who were each known for a particular skill. One of these Gems was Birbal, known for his wit and wisdom. The story below is one of the examples of his wit. Do you have it in you to find the answer?
One day the Emperor Akbar stumbled on a small rock in the royal gardens and momentarily went off balance. He was in a bad mood that day and the incident only served to make him more angry. Finding a target for his mood of the day, he ordered the gardener's arrest and execution. Birbal heard of this and visited the gardener in the cell where he was being held awaiting execution. Birbal had known the gardener for many years and also knew of the gardener's immense respect and sense of loyalty for the king. He decided to help the gardener escape the death sentence and explained his plan to the gardener, who reluctantly agreed to go along.
The next day the gardener was asked what his last wish was before he was hanged, as was custom. The gardener requested an audience with the emperor. This wish was granted, but when the man neared the throne he tried to attack the emperor. The emperor was shocked and demanded an explanation. The gardener looked at Birbal, who stepped forward and explained why the gardener had attacked the emperor. The emperor immediately realised how unjust he had been and ordered the release of the gardener. How did Birbal manage this?

"Your Majesty," said Birbal, "there is probably no person more loyal to you than this unfortunate gardener. Fearing that people would say you hanged him for a silly reason and question your sense of justice, he went out of his way to give you a genuine reason for hanging him."

Dave and Brad, two popular politicians, met at a club to discuss the overthrow of their party leader. They each ordered a vodka on the rocks. Brad downed his and ordered another. He then drank his second in a gulp and decided to wait before he ordered a third. Meanwhile, Dave, who was sipping his drink, suddenly fell forward dead. Both men were setup for an assassination. Why did Dave die and Brad live?

Both Dave and Brad were given drinks with poisoned ice cubes. Brad drank his drinks so quickly that the ice didn't have time to melt and release the poison.

Bill and Stacie are delighted when their new baby, Patrick, is born on February 29th, 2008. They think it's good luck to for him to be born on the special day of the leap year. But then they start thinking about when to celebrate his next birthday. After some thought, they decide that they want to celebrate Patrick's next birthday (when he turns 1) exactly 365 days after he was born, just like most people do.
What will be the date of this birthday?

The date of the birthday will be February 28th, 2009.
At first it might seem like his birthday should be March 1st, 2009, since February 29th is the day after February 28th in the leap year, while March 1st is the day after February 28th in non-leap years. But this is the wrong way to think about it.
The right way to think about it is that 365 days after the day before March 1st is always February 28th, regardless of whether it's a leap year or not. So Patrick's birthday will be February 28th.