Best riddles

funnytrickycrazy

Your bike crashed into the dark forest and suddenly you saw and deadly panther and jaguar. You got just one bullet. What is your escape strategy?
Simple, you must shoot the panther and drive off in the jaguar (car).
84.15 %
44 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
84.15 %
44 votes
logicmath

Note: This riddle must be done IN YOUR HEAD ONLY and NOT using paper and a pen. Take 1000 and add 40 to it. Now add another 1000. Now add 30. Another 1000. Now add 20. Now add another 1000. Now add 10. What is the total?
The answer is 4100, check it out on a calculator. Did you think it was 5000? Most people add the 100 as 1000 by mistake.
84.15 %
44 votes
logicmathsimpleclean

I know a number which when multiplied by multiple of 9 i.e 9 18 27 36 45 ... The output consist of number containing only one digit. Can you identify the number?
12345679 12345679 × 9 = 111111111 (only 1s) 12345679 × 18 = 222222222 (only 2s) 12345679 × 27 = 333333333 (only 3s) 12345679 × 36 = 444444444 (only 4s) 12345679 × 45 = 555555555 (only 5s)
84.15 %
44 votes