Logic riddles

logictrickysimple

A man was driving a truck at 60 mph. He did not have his headlights on and the moon was not up. Yet he did not hit the woman who crossed the road. How?
He was driving the truck during daytime.
81.65 %
45 votes
logicclean

Can you punctuate the following, in order to make it a proper English sentence? I said that that that that that man wrote should have been underlined
I said that, "that 'that' that that man wrote should have been underlined."
81.65 %
45 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
81.65 %
45 votes
logiccleancleverstory

Once upon a time, in the West Lake village, a servant lived with his master. After service of about 30 years, his master became ill and was going to die. One day, the master called his servant and asked him for a wish. It could be any wish but just one. The master gave him one day to think about it. The servant became very happy and went to his mother for discussion about the wish. His mother was blind and she asked her son for making a wish for her eye-sight to come back. Then the servant went to his wife. She became very excited and asked for a son as they were childless for many years. After that, the servant went to his father who wanted to be rich and so he asked his son to wish for a lot of money. The next day he went to his master and made one wish through which all the three (mother, father, wife) got what they wanted. You have to tell what the servant asked the master.
The servant said, "My mother wants to see her grandson swinging on a swing of gold."
81.57 %
66 votes
logic

Find a short hidden message in the list of words below. carrot fiasco nephew spring rabbit sonata tailor bureau legacy corona travel bikini object happen soften picnic option waited effigy adverb report accuse animal shriek esteem oyster
Starting with the first two words, take the first and last letters, reading from left to right. Example: Carrot fiascO "from these pairs" the message is as follows: CONGRATULATIONS CODE BREAKER
81.57 %
66 votes
logicsimple

This is a newspaper headline: Workers Strike - Want to Make Less Money! What is going on?
The workers work at the mint and are tired of being overworked. They want to work less, which is making less money, since money is made at the mind!
81.57 %
52 votes