Once there was a night watchman who had been caught several times sleeping on the job. The boss issued the final warning. On the next night he was caught with his head on his hand and his elbows on the desk. "Aha, I've caught you again," exclaimed the boss. The watchman's eyes popped open immediately and he knew what had happened. Being a quick thinking man, he said one word before looking up at the boss. The boss apologized profusely and went home. What was the one word?
The one word was "AMEN", thus making the Boss believe he was praying rather than sleeping.
See also best riddles or new riddles.cleanlogicshort
It is impossible to keep it until you give it someone else. What is that?
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
Why is 6 afraid of 7?
Because seven was hungry and 'seven ate nine' (7, 8, 9).logic
You die and the devil says he'll let you go to heaven if you beat him in a game. The devil sits you down at a perfectly round table. He gives himself and you an infinite pile of quarters. He says, "OK, we'll take turns putting one quarter down, no overlapping allowed, and the quarters must rest flat on the table surface. The first guy who can't put a quarter down loses." You guys are about to start playing, and the devil says that he'll go first. However, at this point you immediately interject, and ask if you can go first instead. You make this interjection because you are very smart and can place quarters perfectly, and you know that if you go first, you can guarantee victory. Explain how you can guarantee victory.
You place a quarter right in the center of the table. After that, whenever the devil places a quarter on the table, mimic his placement on the opposite side of the table.. If he has a place to place a quarter, so will you. The devil will run out of places to put a quarter before you do. cleanlogic
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.cleanEinstein’slogic
There are 5 ships in a port.
The Greek ship leaves at six and carries coffee.
The ship in the middle has a black chimney.
The English ship leaves at nine.
The French ship with a blue chimney is to the left of a ship that carries coffee.
To the right of the ship carrying cocoa is a ship going to Marseille.
The Brazilian ship is heading for Manila.
Next to the ship carrying rice is a ship with a green chimney.
A ship going to Genoa leaves at five.
The Spanish ship leaves at seven and is to the right of the ship going to Marseille.
The ship with a red chimney goes to Hamburg.
Next to the ship leaving at seven is a ship with a white chimney.
The ship on the border carries corn.
The ship with a black chimney leaves at eight.
The ship carrying corn is anchored next to the ship carrying rice.
The ship to Hamburg leaves at six.
Which ship goes to Port Said? Which ship carries tea?
The French ship.logic
Many years ago a wealthy old man was near death. He wished to leave his fortune to one of his three children. The old man wanted to know that his fortune would be in wise hands. He stipulated that his estate would be left to the child who would sing him half as many songs as days that he had left to live.The eldest son said he couldn't comply because he didn't know how many days his father had left to live and besides he was too busy. The youngest son said the same thing. The man ended up leaving his money to his third child a daughter. What did his daughter do?
Every other day, the daughter sang her father a song.logicmathshort
Dean Sam and Castiel are three brothers.
Interestingly their current age is prime.
What's more interesting that difference between their ages is also prime.
How old are they?
Sam : 2
Dean : 5
Castiel : 7
7 - 2 = '5' is prime
7 - 5 = '2' is prime
5 - 2 = '3' is primecleanlogicshort
What comes down and goes up again and again? What is that?
Raiun. It falls on the ground, evaporates, forms into clouds and falls as rain again.
Your enemy challenges you to play Russian Roulette with a 6-cylinder pistol (meaning it has room for 6 bullets). He puts 2 bullets into the gun in consecutive slots, and leaves the next four slots blank. He spins the barrel and hands you the gun. You point the gun at yourself and pull the trigger. It doesn't go off. Your enemy tells you that you need to pull the trigger one more time, and that you can choose to either spin the barrel at random, or not, before pulling the trigger again. Spinning the barrel will position the barrel in a random position.
Assuming you'd like to live, should you spin the barrel or not before pulling the trigger again?
You are better off shooting again without spinning the barrel.
Given that the gun didn't fire the first time, it was pointing to one of the four empty slots. Because your enemy spun the cylinder randomly, it would have been pointing to any of these empty slots with equal probability. Three of these slots would not fire again after an additional trigger-pull, and one of them would. Thus, by not spinning the barrel, there is a 1/4 chance that pulling the trigger again would fire the gun.
Alternatively, if you spin the barrel, it will point to each of the 6 slots with equal probability. Because 2 of these 6 slots have bullets in them, there would be a 2/6 = 1/3 chance that the gun would fire after spinning the barrel.
Thus, you are better off not spinning the barrel.