Best riddles

logiccleverstory

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.
71.90 %
97 votes
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) 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
71.88 %
55 votes
logicsimpleclean

A man had a book that was worth $40,000. There were only 2 books in existence. He threw it in the furnace, reducing it to a pile of soot. Why did he do this?
He destroyed the book because he has two, and by only having one, the value goes up.
71.88 %
55 votes
cleansimplelogic

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."
71.88 %
55 votes
cleanfunnytricky

A hungry donkey was tied to a rope eight feet long. About thirty feet away there was a basket of fresh carrots. The donkey wanted to eat those carrots. How did he reach them?
It's not tied to anything else!
71.83 %
109 votes
logiccleansimple

A farmer is travelling with a fox, a sheep and a small sack of hay. He comes to a river with a small boat in it. The boat can only support the farmer and one other animal/item. If the farmer leaves the fox alone with the sheep, the fox will eat the sheep. And if the farmer leaves the sheep alone with the hay, the sheep will eat the hay. How can the farmer get all three as well as himself safely across the river?
The farmer takes the sheep across the river, then returns back. The farmer takes the fox across the river. The farmer takes the sheep back to the first side of the river. The farmer leaves the sheep back on the first side of the river, and takes the hay to the other side. The farmer returns to the first side of the river. The farmer brings the sheep back to the second side.
71.81 %
117 votes