## Rectangular house

A man builds a house rectangular in shape. All sides have southern exposure. A big bear walks by, what color is the bear? Why?

White. The house is at the North Pole, so the polar bear.

A man builds a house rectangular in shape. All sides have southern exposure. A big bear walks by, what color is the bear? Why?

White. The house is at the North Pole, so the polar bear.

See also best riddles or new riddles.

What does this stand for?
26 Ls of the A

26 Letters of the Alphabet.

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

One day, Emperor Akbar posed a question to Birbal. He asked him what Birbal would choose if he offered either justice or a gold coin.
"The gold coin," said Birbal without hesitation.
On hearing this, Akbar was taken aback. "You would prefer a gold coin to justice?" he asked, not believing his own ears.
"Yes," said Birbal.
The other courtiers were amazed by Birbal's display of idiocy. They were full of glee that Birbal had finally managed himself to do what these courtiers had not been able to do for a long time - discredit Birbal in the emperor's eyes!
"I would have been disappointed if this was the choice made even by my lowliest of servants," continued the emperor. "But coming from you it's not only disappointing, but shocking and sad. I did not know you were so debased!"
How did Birbal justify his answer to the enraged and hurt Emperor?

"One asks for what one does not have, Your Majesty." said Birbal, smiling gently and in quiet tones.
"Under Your Majesty´s rule, justice is available to everybody. But I am a spendthrift and always short of money and therefore I said I would choose the gold coin."
The answer immensely pleased the emperor and respect for Birbal was once again restored in the emperor's eyes.

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?
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.

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.

Think of a number. Double it. Add ten. Half it. Take away the number you started with. What is your number?

Your number is 5.

You overhear a man talking to a clerk in a hardware store. The clerk says "One will cost you 12 cents, ten will cost your 24 cents, and one hundred will cost you 36 cents."
What is the man buying?

The man is buying physical numbers to nail to the front of his house. Each number costs 12 cents, and so "1" will cost 12 cents, "10" will cost 24 cents, and "100" will cost 36 cents.

When will a net hold water?

When the water is frozen.

August was the name of a puppy who was always picking on larger animals. One day he got into an argument with a lion. The next day was the first day of September. Why?

Because that was the last of August.

There were two women, standing and facing the opposite ways. The first lady was facing south and the second lady was facing north. But, they could see each other. How is that possible?

They were holding the mirror.

You have been given the task of transporting 3,000 apples 1,000 miles from Appleland to Bananaville. Your truck can carry 1,000 apples at a time. Every time you travel a mile towards Bananaville you must pay a tax of 1 apple but you pay nothing when going in the other direction (towards Appleland). What is highest number of apples you can get to Bananaville?

833 apples.
Step one: First you want to make 3 trips of 1,000 apples 333 miles. You will be left with 2,001 apples and 667 miles to go.
Step two: Next you want to take 2 trips of 1,000 apples 500 miles. You will be left with 1,000 apples and 167 miles to go (you have to leave an apple behind).
Step three: Finally, you travel the last 167 miles with one load of 1,000 apples and are left with 833 apples in Bananaville.