Best riddles

logicmysterydetective

Dave and Brad, two popular politicians, met at a club to discuss the overthrow of their party leader. They each ordered a vodka on the rocks. Brad downed his and ordered another. He then drank his second in a gulp and decided to wait before he ordered a third. Meanwhile, Dave, who was sipping his drink, suddenly fell forward dead. Both men were setup for an assassination. Why did Dave die and Brad live?
Both Dave and Brad were given drinks with poisoned ice cubes. Brad drank his drinks so quickly that the ice didn't have time to melt and release the poison.
68.12 %
349 votes
tricky

A man hijacks an aeroplane transporting both passengers and valuable cargo. After taking the cargo, the man demands two parachutes, puts one of them on, and jumps, leaving the other behind. Why did he want two?
If the officials thought he was jumping with a hostage, they would never risk giving him a faulty parachute.
68.05 %
81 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
68.01 %
59 votes
logicmathtricky

A train leaves from Halifax, Nova Scotia heading towards Vancouver, British Columbia at 120 km/h. Three hours later, a train leaves Vancouver heading towards Halifax at 180 km/h. Assume there's exactly 6000 kilometers between Vancouver and Halifax. When they meet, which train is closer to Halifax?
Both trains would be at the same spot when they meet therefore they are both equally close to Halifax.
67.98 %
88 votes