A Collection of Quant Riddles With Answers


How many degrees (if any) are there in the angle between the hour and minute hands of a clock when the time is a quarter past three?
each hour is made up of 30° and that the hour hand will have moved one quarter of an hour past three o'clock. ¼ x 30° = 7.5°

There are 100 light bulbs lined up in a row in a long room. Each bulb has its own switch and is currently switched off. The room has an entry door and an exit door. There are 100 people lined up outside the entry door. Each bulb is numbered consecutively from 1 to 100. So is each person.

Person No. 1 enters the room, switches on every bulb, and exits. Person No. 2 enters and flips the switch on every second bulb (turning off bulbs 2, 4, 6...). Person No. 3 enters and flips the switch on every third bulb (changing the state on bulbs 3, 6, 9...). This continues until all 100 people have passed through the room.

What is the final state of bulb No. 64? And how many of the light bulbs are illuminated after the 100th person has passed through the room?
http://puzzles.nigelcoldwell.co.uk/six.htm
There are 10 square numbers between 1 and 100 (1, 4, 9, 16, 25, 36, 49, 64, 81 & 100) hence 10 bulbs remain on.


8. What is the smallest positive integer that leaves a remainder of 1 when divided by 2, remainder of 2 when divided by 3, a remainder of 3 when divided by 4, and so on up to a remainder of 9 when divided by 10?
http://puzzles.nigelcoldwell.co.uk/eight.htm

N + 1 is divisible by 2, 3, 4, 5, 6, 7, 8, 9 & 10
The lowest value for N + 1 is 2520, which means the lowest value for N is: 2519

9. In a certain matriarchal town, the women all believe in an old prophecy that says there will come a time when a stranger will visit the town and announce whether any of the men folks are cheating on their wives. The stranger will simply say "yes" or "no", without announcing the number of men implicated or their identities. If the stranger arrives and makes his announcement, the women know that they must follow a particular rule: If on any day following the stranger's announcement a woman deduces that her husband is not faithful to her, she must kick him out into the street at 10 A.M. the next day. This action is immediately observable by every resident in the town. It is well known that each wife is already observant enough to know whether any man (except her own husband) is cheating on his wife. However, no woman can reveal that information to any other. A cheating husband is also assumed to remain silent about his infidelity.

The time comes, and a stranger arrives. He announces that there are cheating men in the town. On the morning of the 10th day following the stranger's arrival, some unfaithful men are kicked out into the street for the first time. How many of them are there?
http://puzzles.nigelcoldwell.co.uk/nine.htm

N cheating husbands:

Any of the wives being cheated on will be aware of N-1 cheating husbands and expect the process to be solved on the (N-1)th day, when this doesn't happen they all become aware that all the other wives that they thought were being cheated were all under the same impression and hence they must be the Nth cheated on wife. Hence on the Nth day N wives throw out N husbands.
Hence the answer, on the 10th day: 10 men are thrown out.

Number Game Call Out 50
http://puzzles.nigelcoldwell.co.uk/ten.htm
10. You and I are to play a competitive game. We shall take it in turns to call out integers. The first person to call out '50' wins. The rules are as follows:
–The player who starts must call out an integer between 1 and 10, inclusive;
–A new number called out must exceed the most recent number called by at least one and by no more than 10. 

Do you want to go first, and if so, what is your strategy?

W wins if he says 50, he can say this if...
L says any number in the range 40 - 49 and will have to say one of these if...
W says 39, he can say this if...
L says any number in the range 29 - 38 and will have to say one of these if...
W says 28, he can say this if...
L says any number in the range 18 - 27 and will have to say one of these if...
W says 17, he can say this if...
L says any number in the range 7 - 16 and will have to say one of these if...
W starts on 6.
So that is pretty much it. W wins if he starts on 6 then simply follows the sequence 6, 17, 28, 39, 50. Another way of thinking about this is that W forces each pair of numbers to go up in 11's regardless of what L says, hence he starts on 6 which is 50 - 4x11. 

Inside of a dark closet are five hats: three blue and two red. Knowing this, three smart men go into the closet, and each selects a hat in the dark and places it unseen upon his head.

Three Men and Red & Blue Hats
http://puzzles.nigelcoldwell.co.uk/twelve.htm
Once outside the closet, no man can see his own hat. The first man looks at the other two, thinks, and says, "I cannot tell what color my hat is." The second man hears this, looks at the other two, and says, "I cannot tell what color my hat is either." The third man is blind. The blind man says, "Well, I know what color my hat is." What color is his hat?

A does not know what colour hat he is wearing. A would only know what colour hat he was wearing if he could see that B & C were both wearing red hats, (as there were only two red hats in the cupboard.) This is not the case so either:-
B & C are both wearing blue hats
OR
one of B & C is wearing red and the other is wearing blue
When B speaks we obviously assume he has thought of all of this. When B looks at C if C were wearing redthen he would know that he must be wearing blue as they can't both be wearing red. But this does not happen so C must be wearing blue, meaning that B doesn't know if he is wearing red or blue:

The third person must be wearing a BLUE hat. 

Circular Field, Hungry Dog
http://puzzles.nigelcoldwell.co.uk/thirteen.htm   
13. You are standing at the centre of a circular field of radius R. The field has a low wire fence around it. Attached to the wire fence (and restricted to running around the perimeter) is a large, sharp-fanged, hungry dog. You can run at speed v, while the dog can run four times as fast. What is your running strategy to escape the field?

(1 - x)R/v = πR/(4v)

x = 0.2146

The strategy is to run in a circle of 0.2146R < radius < 0.25R until the dog is on the opposite side then make for the fence like the clappers.

52 Cards Win a Dollar
http://puzzles.nigelcoldwell.co.uk/fourteen.htm
14. You have 52 playing cards (26 red, 26 black). You draw cards one by one. A red card pays you a dollar. A black one fines you a dollar. You can stop any time you want. Cards are not returned to the deck after being drawn. What is the optimal stopping rule in terms of maximizing expected payoff?

Also, what is the expected payoff following this optimal rule?

Prime Squared Minus 1 Multiple of 24
http://puzzles.nigelcoldwell.co.uk/fifteen.htm
15. Why is it that if 'p' is a prime number bigger than 3, then p2-1 is always divisible by 24 with no remainder?

p2 - 1 = (p - 1) x (p + 1)= 2*2*28*3 *X
p is 5.

One Minute Inhomogeneous Fuse
http://puzzles.nigelcoldwell.co.uk/seventeen.htm
17. You have a string-like fuse that burns in exactly one minute. The fuse is inhomogeneous, and it may burn slowly at first, then quickly, then slowly, and so on. You have a box of matches, and no watch. How do you measure exactly 30 seconds? 
If you had 2 fuses could you measure 45 seconds?

Mean of Consecutive Primes
http://puzzles.nigelcoldwell.co.uk/eighteen.htm
18. Can the mean of any two consecutive prime numbers ever be prime?
By definition of mean the result must be between the two source numbers. 

By definition of consecutive there can't be a prime number in between two consecutive prime numbers. 

100 Factorial
http://puzzles.nigelcoldwell.co.uk/nineteen.htm
19. How many consecutive zeros are there at the end of 100! (100 factorial). How would your solution change if the problem were in base 5? How about in Binary???
Base five is a counting system where rather than there being 10 available digits (0 - 9) there are 5 (0 - 4)
So the first few numbers in base 5 are 1, 2, 3, 4, 10, 11, 12, 13, 14, 20, 21... ...43, 44, 100, 101, 102... 

Now in Binary....

ow we just need to add up the number of factors of 2, 4, 8, 16, 32 & 64 
FactorsOccurrences
250
425
812
166
323
641
total97

The Brick, The Boat and The Lake
http://puzzles.nigelcoldwell.co.uk/twentyone.htm
21. A man is in a rowing boat floating on a lake, in the boat he has a brick. He throws the brick over the side of the boat so as it lands in the water. The brick sinks quickly. The question is, as a result of this does the water level in the lake go up or down?

The Water Level Goes Down!!!!
So when the brick is in the boat it is displacing it's own mass equivalence in water. When the brick is thrown over the side it is displacing it's own volume in water. 
So the volume of water equivalent to the mass of the brick is greater than the volume of the brick. And so less water is displaced after than before. Hence...

The 3 & 5 Litre Die Hard Water Puzzle
http://puzzles.nigelcoldwell.co.uk/twentytwo.htm
22. You have a 3 and a 5 litre water container, each container has no markings except for that which gives you it's total volume. You also have a running tap. You must use the containers and the tap in such away as to exactly measure out 4 litres of water. How is this done?

Number 1 5-1=4

  • Fill the 5 litre can from the tap
  • Empty the 5 litre can into the 3 litre can - leaving 2 litres in the 5 litre can.
  • Poor away the contents of the 3 litre can.
  • Fill the 3 litre can with the 2 litres from the 5 litre can - leaving 2 litres in the 3 litre can.
  • Fill the 5 litre can from the tap.
  • Fill the remaining 1 litre space in the 3 litre can from the 5 litre can.
    Leaving 4 litres in the 5 litre can.
Number 2 1+3=4
  • Fill the 3 litre can from the tap.
  • Empty the contents of the 3 litre can into the 5 litre can.
  • Fill the 3 litre can from the tap.
  • Empty the contents of the 3 litre can into the 5 litre can. - Leaving the 5 litre can full and 1 litre in the 3 litre can.
  • Poor away the contents of the 5 litre can
  • Poor the 1 litre from the 3 litre can into the 5 litre can.
  • Fill the 3 litre can from the tap.
  • Empty the contents of the 3 litre can into the 5 litre can.
    Leaving 4 litres in the 5 litre can.


Envelopes, Stick or Change
http://puzzles.nigelcoldwell.co.uk/twentythree.htm
23. I have three envelopes, into one of them I put a £20 note. I lay the envelopes out on a table in front of me and allow you to pick one envelope. You hold but do not open this envelope. I then take one of the envelopes from the table, demonstrate to you that it was empty, screw it up and throw it away. The question is would you rather stick with the envelope you have selected or exchange it for the one on the table. Why? What would be the expected value to you of the exchange?

Simply before the exchange you have 1/3 of £20 and afterwards you will have 2/3 of £20, ie the advantage to you is about £6.66.

The Market
http://puzzles.nigelcoldwell.co.uk/twentyfour.htm
24. You're a farmer. You're going to a market to buy some animals. On the market there are 3 types of animals for sale. You can buy: Horses for £10 each, goats for £1 each and ducks, you get 8 of these per bunch and each bunch costs £1. The aim is to acquire 100 animals at the cost of £100, what is the combination of horses, goats and duck that allows you to do this? (you must buy at least one of each.)

Our equations are:
10*H + G + D/8 = 100 (pounds)
H + G + D = 100 (animals)

72H = 7D
H = 7 : D = 72 : G = 21
The answer is 7 horses, 21 goats and 9 bunches of duck.

Puzzle #25: Bridge crossing in 17 Minutes with Torch

Number of Squares on a Chessboard

27. How many squares are there on a chessboard or chequerboard?? (the answer is not 64) 
Can you extend your technique to calculate the number of rectangles on a chessboard?

Formula For n x n Chessboard?
n2 + (n-1)2 + (n-2)2 ... ... 22 + 12
n3/3 + n2/2 + n/6

Can you extend your technique to calculate the number of rectangles on a chessboard?
The vertices are the intersections. For our chessboard there are 81 (9 x 9). A diagonal starting at one vertex and ending at another will uniquely describe a rectangle. In order to be a diagonal and not a vertical or horizontal line we may start anywhere but the end point must not have the same vertical or horizontal coordinate. As such there are 64 (8 x 8) possible end points. 

There are therefore 81 x 64 = 5184 acceptable diagonals. 

However, whilst each diagonal describes a unique rectangle, each rectangle does not describe a unique diagonal. 

diagonals for rectagles, there are four diagonals that describe the same rectangle
We see trivially that each rectangle can be represented by 4 diagonals. 

So our number of rectangles is given by 81 x 64 /4 = 1296
n x n or n x m?

The n x n or n x m problems can now be calculated. The number of vertices being given by (n + 1)2 and (n + 1).(m + 1) respectively. Hence the final solutions are as follows.

n x n: (n + 1)2 x n2 / 4
n x m: (n + 1) x (m + 1) x (n x m) / 4 

Ali and the 8 Loaves

29. There were two men having a meal. The first man brought 5 loaves of bread, and the second brought 3. A third man, Ali, came and joined them. They together ate the whole 8 loaves. As he left Ali gave the men 8 coins as a thank you. The first man said that he would take 5 of the coins and give his partner 3, but the second man refused and asked for the half of the sum (i.e. 4 coins) as an equal division. The first one refused. 

They went to Ali and asked for the fair solution. Ali told the second man, "I think it is better for you to accept your partner's offer." But the man refused and asked for justice. So Ali said, "then I say that who offered 5 loaves takes 7 coins, and who offered 3 loaves takes 1 coin." 

Can you explain why this was actually fair?
We could reasonably think that the 3 men would have shared the loaves equally eating 2 ⅔ loaves each. Meaning that the actual contributions of the ment was less: 

Person #1: 5 - 2 ⅔ = 2 ⅓ 

Person #2: 3 - 2 ⅔ = ⅓ Now looking at their net contributions, person #1 gave 2 ⅓ loaves, or looking at it in thirds they gave 7 thirds as opposed to person #2 who gave just 1 third. 

Man With 3 Daughters of Different Ages
http://puzzles.nigelcoldwell.co.uk/thirtyfour.htm
34. A man has three daughters. A second, intelligent man, asked him the ages of his daughters. The first man told him that the product of their ages (them all multiplied together,) was 36. After thinking the second man was unable to find the answer and asked for another clue. The first man replies the sum of their ages is equal to his house door number. Still the second man was unable to answer and asked for another clue. The first man told him that his youngest daughter had blue eyes, and suddenly second man gave the correct answer. Explain how?

13: 1, 6, 6
13: 2, 2, 9
It's reasonable to assume that the second man took this to mean that the two youngest daughters were not the same age, that there was a youngest daughter. This is not the case with the ages 2, 2 & 9. The only possible solution is 1, 6 & 6

When the Hands of a Clock First Overlap
http://puzzles.nigelcoldwell.co.uk/thirtyfive.htm
35. A regular clock has an hour and minute hand. At 12 midnight the hands are exactly aligned. When is the next time they will exactly align or overlap?

#36: N Face Up Cards In A Dark Room
http://puzzles.nigelcoldwell.co.uk/thirtysix.htm
36. You are in a dark room with a deck of cards. N of the cards are face up and the rest are face down. You can't see the cards. How do you divide the deck in to two piles with equal numbers of face up cards in each?

The answer is we take N cards, any N cards, from the deck to form a second pile and flip all the cards in the second pile. The second pile will then contain as many face up cards as the first pile.

#38: Probability of Seeing a Car in 10 Minutes & 30 Minutes
http://puzzles.nigelcoldwell.co.uk/thirtyeight.htm
38. On a deserted road, the probability of observing a car during a thirty-minute period is 95%. What is the chance of observing a car in a ten-minute period?

P(not30)=P(not10)^3
P(not10) = cube root (0.05) = 0.3684 roughly

Read full article from A Collection of Quant Riddles With Answers

Labels

LeetCode (1432) GeeksforGeeks (1122) LeetCode - Review (1067) Review (882) Algorithm (668) to-do (609) Classic Algorithm (270) Google Interview (237) Classic Interview (222) Dynamic Programming (220) DP (186) Bit Algorithms (145) POJ (141) Math (137) Tree (132) LeetCode - Phone (129) EPI (122) Cracking Coding Interview (119) DFS (115) Difficult Algorithm (115) Lintcode (115) Different Solutions (110) Smart Algorithm (104) Binary Search (96) BFS (91) HackerRank (90) Binary Tree (86) Hard (79) Two Pointers (78) Stack (76) Company-Facebook (75) BST (72) Graph Algorithm (72) Time Complexity (69) Greedy Algorithm (68) Interval (63) Company - Google (62) Geometry Algorithm (61) Interview Corner (61) LeetCode - Extended (61) Union-Find (60) Trie (58) Advanced Data Structure (56) List (56) Priority Queue (53) Codility (52) ComProGuide (50) LeetCode Hard (50) Matrix (50) Bisection (48) Segment Tree (48) Sliding Window (48) USACO (46) Space Optimization (45) Company-Airbnb (41) Greedy (41) Mathematical Algorithm (41) Tree - Post-Order (41) ACM-ICPC (40) Algorithm Interview (40) Data Structure Design (40) Graph (40) Backtracking (39) Data Structure (39) Jobdu (39) Random (39) Codeforces (38) Knapsack (38) LeetCode - DP (38) Recursive Algorithm (38) String Algorithm (38) TopCoder (38) Sort (37) Introduction to Algorithms (36) Pre-Sort (36) Beauty of Programming (35) Must Known (34) Binary Search Tree (33) Follow Up (33) prismoskills (33) Palindrome (32) Permutation (31) Array (30) Google Code Jam (30) HDU (30) Array O(N) (29) Logic Thinking (29) Monotonic Stack (29) Puzzles (29) Code - Detail (27) Company-Zenefits (27) Microsoft 100 - July (27) Queue (27) Binary Indexed Trees (26) TreeMap (26) to-do-must (26) 1point3acres (25) GeeksQuiz (25) Merge Sort (25) Reverse Thinking (25) hihocoder (25) Company - LinkedIn (24) Hash (24) High Frequency (24) Summary (24) Divide and Conquer (23) Proof (23) Game Theory (22) Topological Sort (22) Lintcode - Review (21) Tree - Modification (21) Algorithm Game (20) CareerCup (20) Company - Twitter (20) DFS + Review (20) DP - Relation (20) Brain Teaser (19) DP - Tree (19) Left and Right Array (19) O(N) (19) Sweep Line (19) UVA (19) DP - Bit Masking (18) LeetCode - Thinking (18) KMP (17) LeetCode - TODO (17) Probabilities (17) Simulation (17) String Search (17) Codercareer (16) Company-Uber (16) Iterator (16) Number (16) O(1) Space (16) Shortest Path (16) itint5 (16) DFS+Cache (15) Dijkstra (15) Euclidean GCD (15) Heap (15) LeetCode - Hard (15) Majority (15) Number Theory (15) Rolling Hash (15) Tree Traversal (15) Brute Force (14) Bucket Sort (14) DP - Knapsack (14) DP - Probability (14) Difficult (14) Fast Power Algorithm (14) Pattern (14) Prefix Sum (14) TreeSet (14) Algorithm Videos (13) Amazon Interview (13) Basic Algorithm (13) Codechef (13) Combination (13) Computational Geometry (13) DP - Digit (13) LCA (13) LeetCode - DFS (13) Linked List (13) Long Increasing Sequence(LIS) (13) Math-Divisible (13) Reservoir Sampling (13) mitbbs (13) Algorithm - How To (12) Company - Microsoft (12) DP - Interval (12) DP - Multiple Relation (12) DP - Relation Optimization (12) LeetCode - Classic (12) Level Order Traversal (12) Prime (12) Pruning (12) Reconstruct Tree (12) Thinking (12) X Sum (12) AOJ (11) Bit Mask (11) Company-Snapchat (11) DP - Space Optimization (11) Dequeue (11) Graph DFS (11) MinMax (11) Miscs (11) Princeton (11) Quick Sort (11) Stack - Tree (11) 尺取法 (11) 挑战程序设计竞赛 (11) Coin Change (10) DFS+Backtracking (10) Facebook Hacker Cup (10) Fast Slow Pointers (10) HackerRank Easy (10) Interval Tree (10) Limited Range (10) Matrix - Traverse (10) Monotone Queue (10) SPOJ (10) Starting Point (10) States (10) Stock (10) Theory (10) Tutorialhorizon (10) Kadane - Extended (9) Mathblog (9) Max-Min Flow (9) Maze (9) Median (9) O(32N) (9) Quick Select (9) Stack Overflow (9) System Design (9) Tree - Conversion (9) Use XOR (9) Book Notes (8) Company-Amazon (8) DFS+BFS (8) DP - States (8) Expression (8) Longest Common Subsequence(LCS) (8) One Pass (8) Quadtrees (8) Traversal Once (8) Trie - Suffix (8) 穷竭搜索 (8) Algorithm Problem List (7) All Sub (7) Catalan Number (7) Cycle (7) DP - Cases (7) Facebook Interview (7) Fibonacci Numbers (7) Flood fill (7) Game Nim (7) Graph BFS (7) HackerRank Difficult (7) Hackerearth (7) Inversion (7) Kadane’s Algorithm (7) Manacher (7) Morris Traversal (7) Multiple Data Structures (7) Normalized Key (7) O(XN) (7) Radix Sort (7) Recursion (7) Sampling (7) Suffix Array (7) Tech-Queries (7) Tree - Serialization (7) Tree DP (7) Trie - Bit (7) 蓝桥杯 (7) Algorithm - Brain Teaser (6) BFS - Priority Queue (6) BFS - Unusual (6) Classic Data Structure Impl (6) DP - 2D (6) DP - Monotone Queue (6) DP - Unusual (6) DP-Space Optimization (6) Dutch Flag (6) How To (6) Interviewstreet (6) Knapsack - MultiplePack (6) Local MinMax (6) MST (6) Minimum Spanning Tree (6) Number - Reach (6) Parentheses (6) Pre-Sum (6) Probability (6) Programming Pearls (6) Rabin-Karp (6) Reverse (6) Scan from right (6) Schedule (6) Stream (6) Subset Sum (6) TSP (6) Xpost (6) n00tc0d3r (6) reddit (6) AI (5) Abbreviation (5) Anagram (5) Art Of Programming-July (5) Assumption (5) Bellman Ford (5) Big Data (5) Code - Solid (5) Code Kata (5) Codility-lessons (5) Coding (5) Company - WMware (5) Convex Hull (5) Crazyforcode (5) DFS - Multiple (5) DFS+DP (5) DP - Multi-Dimension (5) DP-Multiple Relation (5) Eulerian Cycle (5) Graph - Unusual (5) Graph Cycle (5) Hash Strategy (5) Immutability (5) Java (5) LogN (5) Manhattan Distance (5) Matrix Chain Multiplication (5) N Queens (5) Pre-Sort: Index (5) Quick Partition (5) Quora (5) Randomized Algorithms (5) Resources (5) Robot (5) SPFA(Shortest Path Faster Algorithm) (5) Shuffle (5) Sieve of Eratosthenes (5) Strongly Connected Components (5) Subarray Sum (5) Sudoku (5) Suffix Tree (5) Swap (5) Threaded (5) Tree - Creation (5) Warshall Floyd (5) Word Search (5) jiuzhang (5)

Popular Posts