Romeo and Juliet are found dead in a small puddle of water, surrounded by broken glass. The apartment building they are found in is located next to the city's main train station. How did they die?
Romeo and Juliet are fish. A passing train rattled the shelf their tank was sitting on and knocked it off of the shelf. The tank broke and the fish died from being out of the water.
See also best riddles or new riddles.logic
Allan, Bertrand, and Cecil were caught stealing so the king sent them to the dungeon.
But the king decided to give them a chance.
He mad them stand in a line and put hats on their heads.
He told them that if they answer a riddle, they could go free.
Here is the riddle: "Each of you has a hat on your head. You do not know the color of the hat on your own head. If one of you can guess the color of the hat on your head, I will let you free. But before you answer you must keep standing in this line. You cannot turn around. Here are my only hints: there are only black and white hats. At least one hat is black. At least one hat is white."
Allan couldn't see any hats.
Bertrand could see Allan's hat but not his own.
Cecil could see Bertrand's hat and Allan's hat, but not his own.
After a minute nobody had solved the riddle. But then a short while later, one of them solved the riddle. Who was is and how did he know?
Bertrand knew the answer because Cecil didn't say anything after one minute. If Bertrand and Allan's hats were both the same color, then Cecil would know what color his hat was. But Cecil didn't know. So Bertrand knew that Allan's hat was a different color than his. Since Allan's hat was black, Betrand knew his hat was white. logic
At a dinner party, many of the guests exchange greetings by shaking hands with each other while they wait for the host to finish cooking.
After all this handshaking, the host, who didn't take part in or see any of the handshaking, gets everybody's attention and says: "I know for a fact that at least two people at this party shook the same number of other people's hands."
How could the host know this? Note that nobody shakes his or her own hand.
Assume there are N people at the party.
Note that the least number of people that someone could shake hands with is 0, and the most someone could shake hands with is N-1 (which would mean that they shook hands with every other person).
Now, if everyone at the party really were to have shaken hands with a different number of people, then that means somone must have shaken hands with 0 people, someone must have shaken hands with 1 person, and so on, all the way up to someone who must have shaken hands with N-1 people. This is the only possible scenario, since there are N people at the party and N different numbers of possible people to shake hands with (all the numbers between 0 and N-1 inclusive).
But this situation isn't possible, because there can't be both a person who shook hands with 0 people (call him Person 0) and a person who shook hands with N-1 people (call him Person N-1). This is because Person 0 shook hands with nobody (and thus didn't shake hands with Person N-1), but Person N-1 shook hands with everybody (and thus did shake hands with Person 0). This is clearly a contradiction, and thus two of the people at the party must have shaken hands with the same number of people.logicmath
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 horse travels a certain distance each day. Strangely enough, two of its legs travel 30 miles each day and the other two legs travel nearly 31 miles. It would seem that two of the horse's legs must be one mile ahead of the other two legs, but of course this can't be true. Since the horse is normal, how is this situation possible?
The horse operates the mill and travels in a circular clockwise direction. The two outside legs will travel a greater distance than the inside ones.cleanlogicshort
What word becomes shorter when you add two letters to it?
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.cleanlogicmysteryshortwhat am I
I can only live where there is light, but I die if the light shines on me. What am I?
What has an eye but can not see?
Had at work day and night, it counts the numbers over and over. Although it counts all its life, it never gets past twelve.
An iron horse with a flaxen tail.
The faster the horse runs,
the shorter his tail becomes.
What is it?
A needle and thread.