Imagine John, a party magician, is carrying three pieces of gold each piece weighing one kilogram. While taking a walk he comes to a bridge which has a sign posted saying the bridge could hold only a maximum of 80 kilograms. John weighs 78 kilograms and the gold weighs three kilograms. John reads the sign and still safely crossed the bridge with all the gold. How did he manage this?
John is a juggler. When he came to the bridge he juggled the gold, always keeping one piece in the air.
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.
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)
for each character in S1
arrayIndex = mapCharacterToNumber(character) //maps "a" to 0, "b" to 1, "c" to 2, etc...
A[arrayIndex] += 1
for each character in S2
arrayIndex = mapCharacterToNumber(character)
A[arrayIndex] -= 1
for (i = 0; i < 26; i++)
if A[i] != 0
A king decided to let a prisoner try to escape the prison with his life. The king placed 2 marbles in a jar that was glued to a table. One of the marbles was supposed to be black, and one was supposed to be blue. If the prisoner could pick the blue marble, he would escape the prison with his life. If he picked the black marble, he would be executed. However, the king was very mean, and he wickedly placed 2 black marbles in the jars and no blue marbles. The prisoner witnessed the king only putting 2 black marbles in the jars. If the jar was not see-through and the jar was glued to the table and that the prisoner was mute so he could not say anything, how did he escape with his life?
The prisoner grabbed one of the marbles from the jar and concealed it in his hand. He then swallowed it, and picked up the other marble and showed everyone. The marble was black, and since the other marble was swallowed, it was assumed to be the blue one. So the mean king had to set him free.
A blind man walks into a hardware store to buy a hammer. There are hammers hanging behind the front desk, but obviously the blind man isn't able to see them. And yet a few minutes later, he happily walks out of the store, having just purchased a new hammer.
How did he do it?
He walks up the the front desk where the clerk is working and says "I'd like to buy a hammer."
At a local bar, three friends, Mr. Green, Mr. Red and Mr. Blue, were having a drink. One man was wearing a red suit; one a green suit; and the other a blue suit.
"Have you noticed," said the man in the blue suit, "that although our suits have colors corresponding to our names, not one of us is wearing a suit that matches our own names?"
Mr. Red looked at the other two and said, "You're absolutely correct."
What color suit is each man wearing?
Since none of the men are wearing the color of suit that corresponds to their names, and Mr. Red was replying to the man in the blue suit, it had to be Mr. Green to whom he replied. We then know that Mr. Green is wearing a blue suit. Therefore, Mr. Red is wearing a green suit and Mr. Blue is wearing a red suit.
A young woman is attending her mother's funeral. While there, she meets a man she has never seen before and falls in love immediately. After the funeral she tries to find him but cannot. Several days later she kills her sister. Why does she kill her sister?
She killed her sister hoping to see this man at her sisters funeral.
Note: If you thought of this answer easily you may be a psychopath