# Logic riddles

## Blind in a hardware store

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 %

## Six bills

How could you give someone \$63 using six bills without using one dollar bills?
1 - \$50 bill, 1 - \$5 bill, 4 - \$2 bills.
71.88 %

## Anagram Checker

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 %

## Vanilla ice cream

Vanilla ice cream was the most popular flavor and was on display in a little case near the express check out, while the other flavors were in the back of the store and took more time to select and check out. This mattered because the man's car was experiencing vapor lock, which is excess heat boiling the fuel in the fuel line and the resulting air bubbles blocking the flow of fuel until the car has enough time to cool.. When the car was running there was enough pressure to move the bubbles along, but not when the car was trying to start.
71.88 %

## Chimney

What can go up a chimney down but not down a chimney up?
An umbrella.
71.88 %

## I'm many things in one

I'm a fruit. If you take away my first letter, I'm a crime. If you take away my first two letters, I'm an animal. If you take away my first and last letters, I'm a form of music. What am I?
Grape.
71.86 %

## Two Japanese people

Two Japanese people who have never seen each other meet at the New York Japanese Embassy. They decide to have drinks together at a nearby bar. One of them is the father of the other one's son. How is this possible?
The Japanese are husband and wife and both blind since birth.
71.86 %

## Romeo and Juliet

Romeo and Juliet are found dead on the floor in a bedroom. When they were discovered, there were pieces of glass and some water on the floor. The only furniture in the room is a shelf and a bed. The house is in a remote location, away from everything except for the nearby railroad track. What caused the death of Romeo and Juliet?
Romeo and Juliet are fishies. The rumble of the train knocked the tank off the shelf, it broke and Romeo and Julia did not survive.
71.86 %

## A woman with no driver license

A woman with no driver license goes the wrong way on a one-way street and turns left at a corner with a no left turn sign. A policeman sees her but does nothing... Why?
She is walking.
71.85 %