CSE Blog - quant, math, computer science puzzles

Quant, Math & Computer Science Puzzles for Interview Preparation & Brain Teasing
A collection of ~225 Puzzles with Solutions (classified by difficulty and topic)

Feb 18, 2015

Buying in Rocket Ships and Selling in Fire Sale

Source: Asked to me by Ankush Jain (CSE IITB 2011, Morgan Stanley Quant Associate). He took it from Algorithms Design book by Tardos and Kleinberg

Easy case:
You’re trying to buy equipments whose costs are appreciating. Item i appreciates at a rate of r_i > 1 per month, starting from $100, so if you buy it t months from now you will pay 100*((r_i)^t). If
you can only buy one item per month, what is the optimal order in which to buy them?

Difficult case:
You’re trying to sell equipments whose costs are depreciating. Item i depreciates at a rate of r_i < 1 per month, starting from $100, so if you sell it t months from now you will get 100*((r_i)^t). If
you can only sell one item per month, what is the optimal order in which to sell them?

Jan 23, 2015

Box in Box problem

Source: Sent to me by Sudeep Kamath


Airline check-in baggage has size restriction by ​so-called ​linear dimension: length + breadth + height should not exceed 62 inches. Prove that you can't "cheat" by packing a box with higher linear dimension into a box with ​lower​ linear dimension.

Jan 21, 2015

Fibonacci Multiple Puzzle

Source: Mailed to me by Kushagra Singhal, Ex-IIT Kanpur, PhD Student at University of Illinois at Urbana-Champaign


Prove that for any positive K and a natural number n, every (n*K)th number in the Fibonacci sequence is a multiple of the Kth number in the Fibonacci sequence.

More formally, for any natural number n, let F(n) denote Fibonacci number n. That is, F(0) = 0, F(1) = 1, and F(n+2) = F(n+1) + F(n). Prove that for any positive K and natural n, F(n*K) is a multiple of F(K).

Jan 19, 2015

Gold Silver Numbers Puzzle

Source: Mailed to me by JDGM ("regular commenter JDGM")


The integers greater than zero are painted such that:

• every number is either gold or silver.
• both paints are used.
• silver number + gold number = silver number
• silver number * gold number = gold number

Given only this information, for each of the following decide whether it is a gold number, a silver number, or could be either:

1.) gold number * gold number
2.) gold number + gold number
3.) silver number * silver number
4.) silver number + silver number

Dec 28, 2014

Maximum Number of Collinear Points

Source: Asked to me by a friend - who was asked this question in an interview at Facebook


Given n points on a 2D plane, find the equation of the line with maximum number of collinear points. What is the time complexity of your algorithm?