Vous êtes sur la page 1sur 8

CSE Blog - quant, math, computer science puzzles: DifficultPu...

1 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

CSE Blog - quant, math, computer science puzzles


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

Showing posts with label DicultPuzzles. Show all posts


Dec 4, 2010

Probability of Grade A or B
Source: Homepage of Tejaswi Navilarekallu, Post Doctoral Fellow, Vrije Universiteit, Amsterdam
Labels by Diculty

Problem:

DicultPuzzles (64)
EasyPuzzles (87)
MediumPuzzles (93)
Labels by Topic

Algorithm-DataStructures (38)
Brain-Teasers (73)
Discrete-Mathematics (98)
Engineering-Mathematics (19)
Geometry (25)
Number-Theory (31)
Probability (79)
Strategy-Puzzles (50)

Solution:
The solution discussed in a problem before at http://pratikpoddarcse.blogspot.com/2009/10/ndyour-number.html
You might also like

Social
Like

A professor decides the following grading scheme in his class. After the nal exam is graded, he
keeps all the papers upside down on his table in a random order so that no student can
recognize his own paper. Each student during his turn can overturn at most n/2 of these papers
(where n is the total number of students in the class) and guess whether he received an A or a B
on the nal (there are only two grades given). Obviously the student doesn't know which paper
is his, so it is not guaranteed that he will nd his own score by looking at n/2 scores. The papers
are then turned back and kept in the original order. The students cannot pass any information to
others. All the students pass the course if "everyone" guesses their grade correctly, and they fail
otherwise. Come up with a strategy that the students can decide on beforehand, so that the
probability that they all will pass is more than a positive constant independent of n.

Arjun Attam, Nitin Garg and


2,544 others like this.

Baseball Party
Math Olympiad Problem : Overlapping Coins
Senators and Graph Theory
Equal Heads and Tail
Recommended by

Buy me Coee / Beer via Paypal

4 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Probability, Puzzles

Oct 20, 2010

Number of Rounds of Derangements


Source: Asked to me by Sudeep Kamath (Third year PhD Student, UC at Berkeley, EE IITB
Alumnus)
Problem:
There are n men, n hats, one hat belonging to each person. A random permutation of hats is
picked by the men, whoever gets their own hat, takes it and leaves and a random permutation
of the remaining hats is picked and so on. What is the expected number of rounds it takes for
everyone to
leave?
Pages

Hint: Answer is n

Home

Post a Question

Update (21 Oct 2010):


Solution posted by Siddhant Agarwal (Senior Undergraduate, EE, IITB), and a more detailed
explanation posted by me in comments!

About Author

You might also like

Books/Study Material
Social Pages

Disclaimer

Guide to Wall Street Quant Jobs for IITians


Walking Ant Problem - Part 2
Odd Even Algorithm Puzzle

Hits (All Time)

483,868

Weird Number Sequence


Recommended by

Blog Archive

11 comments:

Recommend this on Google

Friday 27 September 2013 01:48 AM

CSE Blog - quant, math, computer science puzzles: DifficultPu...

2 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

Labels: Brain-Teasers, DicultPuzzles, Probability, Puzzles

2013 (34)
2012 (39)
2011 (43)

Oct 14, 2010

2010 (80)

Painting Coloured Balls

Dec 2010 (7)


Water Jug Problem

Source: Asked to me by Sudeep Kamath (Third year PhD Student, UC at Berkeley, EE IITB
Alumnus)

Equal zeroes and ones


Locks and Switches
Order of cards
Stick Broken Into Three Pieces
The Social Network (2010) - FaceMash
Algorithm

Problem: A box contains n balls coloured 1 to n. Each time you pick two balls from the bin - the
rst ball and the second ball, both uniformly at random and you paint the second ball with the
colour of the rst. Then, you put both balls back into the box. What is the expected number of
times this needs to be done so that all balls in the box have the same colour?
You might also like

Probability of Grade A or B

Homo paradox
Nov 2010 (3)

Ants on a Cube

Oct 2010 (10)

Lets Call 50

Sep 2010 (3)

Find Fixed Point (x[i]=i) in an Array

Aug 2010 (4)

Recommended by

Jul 2010 (3)


Jun 2010 (6)

13 comments:

May 2010 (2)

Labels: DicultPuzzles, Discrete-Mathematics, Probability, Puzzles, UnsolvedPuzzles

Recommend this on Google

Apr 2010 (3)


Mar 2010 (7)

Oct 10, 2010

Feb 2010 (8)

Senators and Graph Theory

Jan 2010 (24)


2009 (63)

Source: Asked to me by Sai Teja Pratap (Sophomore Undergraduate, CSE, IITB)

2008 (4)

Problem: There are 51 senators in a senate. The senate needs to be divided into n committees
such that each senator is on exactly one committee. Each senator hates exactly three other
senators. (If senator A hates senator B, then senator B does 'not' necessarily hate senator A.)
Find the smallest n such that it is always possible to arrange the committees so that no senator
hates another senator on his or her committee.

Labels

Puzzles (251)
UnsolvedPuzzles (45)
Innovate (9)
PopularArticles (9)
Coding (8)

15 comments:

UnsolvedCoding (4)

Labels: DicultPuzzles, Discrete-Mathematics, Puzzles, UnsolvedPuzzles

Recommend this on Google

OpenEndedPuzzles (3)
Open Source (2)

Coin Balancing
Popular Posts

Source: Asked to me by Vivek Jha (Senior Undergraduate, EE, IITB)


Integer Points
Lion in a Circular Cage Puzzle
Geometry Puzzle: Center of Square in Circle
Coin Puzzle: Predict the Other's Coin

Problem: Among 10 given coins, some may be real and some may be fake. All real coins weigh
the same. All fake coins weigh the same, but have a dierent weight than real coins. Can you
prove or disprove that all ten coins weigh the same in three weighings on a balance scale?
BTW, List of previously asked Coin related puzzles on the blog:
Russian Coins
Coin Weighing Problem
Another Coin Problem
Coins Puzzle
Consecutive Heads
Five Thieves and Bounty

Asking a girl out


Consecutive Heads
Pizza Distribution Puzzle
Coins Puzzle

Update (Oct 12, 2010)


Solution posted by Gaurav Sinha (chera) (CSE IITK 1996 Graduate, Now working at Indian
Revenue Service) in comments! Reposted by me removing typo.

Sphagetti Breakfast
Math Game of Zero String

Follow by Email!

4 comments:

Submit

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Puzzles, Strategy-Puzzles

Aug 27, 2010

Conway's Soldiers (CheckerBoard Unreachable Line)


Source: Asked to me by Amol Sahasrabudhe (Morgan Stanley Quant Associate)
Problem:
An innite checkerboard is divided by a horizontal line that extends indenitely. Above the line
are empty cells and below the line are an arbitrary number of game pieces, or "soldiers". A move

Friday 27 September 2013 01:48 AM

CSE Blog - quant, math, computer science puzzles: DifficultPu...

3 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

consists of one soldier jumping over an adjacent soldier into an empty cell, vertically or
horizontally (but not diagonally), and removing the soldier which was jumped over. The goal of
the puzzle is to place a soldier as far above the horizontal line as possible.
Prove that there is no nite series of moves that will allow a soldier to advance more than four
rows above the horizontal line.
I could get the correct direction in 5 min. Spent enough time on the problem but could not solve
it. :( Give it a go! \m/
Update: Sep 07, 2010
Solution: Posted by Siddhant Agarwal (Senior Undergraduate, Elec IITB) in comments!!

10 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Puzzles, Strategy-Puzzles

Aug 21, 2010

Magic Money Machine


Source: CMU Puzzle Toad
Problem: The wizards at Wall Street are up to it again. The Silverbags investment bank has
invented the following machine. The machine consists of 6 boxes numbered 1 to 6. When you
rst get the machine, it contains 6 tokens, one in each box. You have two buttons A, B on the
machine and you can press them as many times as you like and in any order.

Button A Choose a number i from 1 to 5 and then take one token from box i and magically two
tokens will be added to box i + 1.
Button B Choose a number i from 1 to 4 and then take one token from box i and then the
contents of boxes i + 1 and i + 2 will be interchanged.
The machine sells for one trillion dollars. The contract says that you can take the machine back
to the bank at any time and then the bank will give you one dollar for each token in the
machine. Is the machine worth buying?
Update (Nov 10, 2010):
This problem is an IMO 2010 Problem. Solution available at artofproblemsolving link
Solution posted by Siddhant Agarwal (EE Senior Undergraduate, IIT Bombay) who gave credits to
Naval Chopra (CSE Senior Undergraduate, IIT Bombay) in comments!

8 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Probability, Puzzles

Jul 25, 2010

Coin conundrum
Source: Australian Mathematical Society Gazette Puzzle Corner
Problem: There are coins of various sizes on a table, with some touching others. As often as you
wish, you may choose a coin, then turn it over, along with every other coin that it touches. If all
coins start out showing heads, is it always possible to change them to all tails using these
moves?
Update (Nov 15, 2010):
Solution: Solution from the gazette author posted by me in comments! Interesting linear
algebra solution posted by Siddhant Agarwal (EE, Senior Undergraduate, IITB) in comments!

5 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Puzzles, Strategy-Puzzles

Diering views
Source: Australian Mathematical Society Gazette Puzzle Corner
Problem: An optimist and a pessimist are examining a sequence of numbers. The optimist
remarks, Oh jolly! The sum of any eight consecutive terms is positive! But the pessimist
interjects, Not so fast, the sum of any ve consecutive terms is negative. Can they both be
right? How long can this sequence of numbers be?

Friday 27 September 2013 01:48 AM

CSE Blog - quant, math, computer science puzzles: DifficultPu...

4 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

Incentive: Treat at H8 Canteen/Sodexho Cafeteria for the rst person to solve it :P


Update (27/07/10): Solution: Posted in comments by Varun Jog (Berkeley Grad Student, EE IITB
Alumnus) and Siddhant Agarwal (EE Senior Undergraduate, IITB)

5 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Number-Theory, Puzzles

Jun 20, 2010

Cube in a sphere
Source: CMU Spring 2010 Course on Great Theoretical Ideas in Computer Science
Problem: 10% of the surface of a sphere is colored green, and the rest is colored blue. Show
that no matter how the colors are arranged, it is possible to inscribe a cube in the sphere so that
all of its vertices are blue.
Hint: Use probabilistic analysis. Consider a random cube and calculate the expected number of
vertices that are blue.
(Update 23/06/10):
Solution: Posted by connect2ppl - Giridhar Addepalli (CSE, IITK alumnus and Yahoo! Sr. Software
Engineer) in comments!

6 comments:

Recommend this on Google

Labels: DicultPuzzles, Geometry, Probability, Puzzles

May 30, 2010

Veit Elsers Formidable 14


Source: CMU Spring 2010 Course on Great Theoretical Ideas in Computer Science Lecture01.
Course pointed to me by Aaditya Ramdas (To be CMU Grad Student & CSE-IITB Alumnus)
Problem:
Fit disks of the following diameters into a circular cavity of size 12.000:
2.150 2.250 2.308 2.348 2.586 2.684 2.684
2.964 2.986 3.194 3.320 3.414 3.670 3.736
Write a program or give a general algorithm to solve a general case.
Disclaimer: Did not spend a lot of time on the problem but I have not been able to solve it.
Clearly sum of the squares of the smaller radii is less than the square of the larger radii
suggesting that it might be possible to t disks. I am not able to make any more comments!

1 comment:

Recommend this on Google

Labels: Algorithm-DataStructures, DicultPuzzles, Discrete-Mathematics, Puzzles, UnsolvedPuzzles

May 7, 2010

Another Hat Problem


Source: Very interesting puzzle from http://forums.xkcd.com/
Problem:
There are 7 people standing in a circle, and each has either a red or a blue hat. The colors of the
hats are chosen uniformly at random (although the problem is much the same if they're chosen
adversarially). The people can't see their own hats, but can see each others'. Everyone is given a
strip of paper and a pen, and simultaneously writes "red", "blue", or "abstain". Nobody can see
what the other people are writing, or convey information in any other way. They win if somebody
guesses his own hat color, and nobody guesses wrong.
Find a strategy (which they agree on ahead of time) that maximizes probability of winning.
Obviously, it is impossible to make a strategy that wins every time, because somebody must
guess and that person has no information.
To make it easier, try it rst with three people.
Disclaimer: I posted this problem (in dierent words) 4 months back here but did not get any
solution. Then I did not have a solution of my own and the solution on the source was too

Friday 27 September 2013 01:48 AM

CSE Blog - quant, math, computer science puzzles: DifficultPu...

5 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

"non-intuitive". Try it again. Its very interesting and trying to solve it gives u a kick :P

5 comments:

Recommend this on Google

Labels: DicultPuzzles, Probability, Puzzles, Strategy-Puzzles

Apr 25, 2010

Oleg Kryzhanovskys Problem - Coin Sequence


Source: http://blog.tanyakhovanova.com/
Problem: You have 6 coins weighing 1, 2, 3, 4, 5 and 6 grams that look the same, except for
their labels. The number (1, 2, 3, 4, 5, 6) on the top of each coin should correspond to its weight.
How can you determine whether all the numbers are correct, using the balance scale only twice?
Disclaimer: It is a dicult problem
Hint: (Highlight from * to * to see the hint) *
Some people post wrong solutions and believe they have solved it. For example, they would
start by putting the coins labeled 1 and 2 on the left cup of the scale and 3 on the right cup. If
these coins balanced, the person assumes that the coins on the left weighed 1 and 2 grams and
that the coin on the right weighed 3 grams. But theyd get the same result if they had 1 and 4
on the left, for example, and 5 on the right.
I propose the following sequence a(n). Suppose we have a set of n coins of dierent weights
weighing exactly an integer number of grams from 1 to n. The coins are labeled from 1 to n. The
sequence a(n) is the minimum number of weighings we need on a balance scale to conrm that
the labels are correct. The original Oleg Kryzhanovskys problem asks to prove that a(6)=2. It is
easy to see that a(1)=0, a(2)=1, a(3)=2. Its fun proving that a(4) = a(5) =2.
*

8 comments:

Recommend this on Google

Labels: Brain-Teasers, DicultPuzzles, Puzzles

Apr 14, 2010

Weighing Piles of Coins


Source: Asked to me by Ankush Agarwal (Sophomore, CSE, IITB)
Problem: There are two kinds of coins, genuine and counterfeit. A genuine coin weighs X
grams and a counterfeit coin weighs X+delta grams, where X is a positive integer and delta is a
non-zero real number strictly between -5 and +5. You are presented with 13 piles of 4 coins
each. All of the coins are genuine, except for one pile, in which all 4 coins are counterfeit. You
are given a precise scale (say, a digital scale capable of displaying any real number). You are to
determine three things: X, delta, and which pile contains the counterfeit coins. But you're only
allowed to use the scale twice!
Prize: Treat at H8 canteen to the rst person who solves it!!

40 comments:

Recommend this on Google

Labels: DicultPuzzles, Puzzles, Strategy-Puzzles, UnsolvedPuzzles

Mar 4, 2010

Trac Jam
You have N cars that are all traveling the same direction on an innitely long one-lane highway.
Unfortunately, they are all going dierent speeds, and cannot pass each other. Eventually the
cars will clump up in one or more trac jams. In terms of N, what is the expected number of
clumps of cars?

Friday 27 September 2013 01:48 AM

CSE Blog - quant, math, computer science puzzles: DifficultPu...

6 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

Update (05/03/2010):
Solution: Posted by me in comments!! Thanx to Asad (EE, IITB Alumnus) and Siddhant Agarwal
(EE, IITB 3rd year student) for their participation in discussion in comments!!
Update (29/01/2011)
Very simple and clear solution posted by wonderwice in comments! Thanks a ton!

10 comments:

Recommend this on Google

Labels: DicultPuzzles, Probability, Puzzles

Mar 2, 2010

Perfect Powers
Source: Appeared in 1977 High School Programming Contest. Taken
from http://www.ocf.berkeley.edu/~wwu/riddles/cs.shtml
Problem:
n

Write a fast program that prints perfect powers (integers of the form m , with m,n>1) in
increasing numerical order.
So the rst few outputs should be 4, 8, 9, 16, 25, 27, 32, ...
Find an algorithm that prints all perfect powers less than equal to N.
Update (05/03/2010):
Solution:
Nikhil Garg (CSE, IITD Sophomore) posted a solution which takes O(N) space and O(log N*sqrt N)
time. Printing takes time O(N) though.
I posted a solution which takes O((sqrt N)*(log N)) space and O((sqrt N)*(log N)*(log N)) time.
Rajendran Thirupugalsamy (Research Assistant, Stony Brook University) posted a solution which
takes O(log(N)) space and O(sqrt N * log N * log(log(N))) time. {Analysis done by Ramdas}
Aaditya Ramdas (CSE IITB Alumnus and working at Tower Research Capital) posted a solution
which takes O(sqrt N) space and O((sqrt N)*(log N)*(log N)) time.
Interesting discussion and all solutions in comments!!

17 comments:

Recommend this on Google

Labels: Algorithm-DataStructures, DicultPuzzles, Number-Theory, Puzzles

Feb 15, 2010

Coin Weighing Problem


Yet another coin problem. Read this today in "Heard from the Street". Found it interesting.
Problem: You are given a set of scales and 90 coins. The scales are of the old balance variety,
that is a small dish hangs from each end of the rod that is balanced in the middle. You must pay
100$ every time you use the scales.
The 90 coins appear to be identical. In fact, 89 of them are identical and one is of a dierent
weight. Your task is to identify the unusual coin and to discard it while minimizing the maximum
possible cost of weighing. What is your algorithm to complete this task?
Note that the unusual coin may be heavier than the others or it may be lighter. You are asked to
both identify it and determine whether it is heavy or light.
Previously asked coin puzzles:
Another Coin Problem
Coins Puzzle

Friday 27 September 2013 01:48 AM

CSE Blog - quant, math, computer science puzzles: DifficultPu...

7 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

Consecutive Heads
Five Thieves and Bounty
Update (18/02/10): Solution posted by me in comments!! A non-optimal but simpler solution
posted by Bhanu (M.Tech Student, CSE, IITB). Another solution posted by Suman in comments!!
Thanx

6 comments:

Recommend this on Google

Labels: Brain-Teasers, DicultPuzzles, Puzzles

Feb 9, 2010

Checkers Problem
Source: Nikhil Garg (Sophomore, IITD) mailed them to me.
Problem 1:
A checker starts at point (1,1). You can move checker using following moves :
1) if it is at (x,y) take it to (2x ,y ) or (x,2y)
2) if it is at (x,y) & x>y take it to (x-y,y)
3) if it is at (x,y) & x<y take it to (x,y-x)
Characterise all lattice points which can be reached.
Problem 2:
You have a checker at (0,0) , (0,1) , (1,0), (2,0), (0,2), (1,1) each. You can make a move as
follows:
if(x,y) is lled & (x+1,y) and (x,y+1) both are empty, remove checker from (x,y) & put one at
each of (x+1,y) and (x,y+1)
Prove that under this move , you can not remove checker from all the six initial points.
Solution:
Update (02/03/10): Solution posted by Nikhil Garg in comments!

2 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Puzzles, Strategy-Puzzles

Jan 29, 2010

Red vs Black cards - Expected payo


This is a variation of the problem discussed some time back: Don't roll More. Just published the
solution to the earlier problem. Thought it would be interesting to solve this problem taken once
again from the book "Heard on The Street".
Problem: You have 52 playing cards (26 black and 26 red). You draw cards one by one. A red
card pays you a dollar. A black card costs you a dollar. You can stop any point you want. Cards
are not returned to the deck after being drawn. What is the optimal stopping rule in terms of
maximizing expected payo? Also, what is the expected payo following the optimal rule?
Hint: Try the problem with 4 cards (2 red, 2 black) :)
Update(29/01/10): Question was incomplete. Added more information.
Solution: (Update (05/02/10)) Idea posted by Aman in comments!! Solution posted by me in
comments!!
The problem/solution is very dicult and not so beautiful. Its not very mathematical though. Do
this only if you have time and you are humble enough to accept defeat :P

10 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Probability, Puzzles

Jan 28, 2010

Three NOT Gates from Two NOT Gates


Problem:
Design a 3-input 3-output logic circuit that negates the 3 signals. You have an infinite supply of AND and OR gates but only two NOT gates

Friday 27 September 2013 01:48 AM

CSE Blog - quant, math, computer science puzzles: DifficultPu...

8 of 8

http://www.cseblog.com/search/label/DifficultPuzzles?updat...

I have read and solved many problems like these. Can people post some similar interesting problems using gates. I was asked one such
question in my Deutsche Bank Interview which I was not able to answer.

Update(09/02/10):
Solution: Solution posted by Sid in comments!!

11 comments:

Recommend this on Google

Labels: DicultPuzzles, Discrete-Mathematics, Engineering-Mathematics, Puzzles

Newer Posts

Home

Older Posts

Subscribe to: Posts (Atom)

Banner

Contributors

amit upadhyay
Pratik Poddar

About CSE Blog

"CSE Blog - Quant, Math & Computer Science Puzzles for Interview
Preparation & Brain Teasing" is a collection of ~225 Puzzles with Solutions.
The problems are divided into three sections: (Easy, Medium and Dicult)
CSE Blog - quant, math, computer science puzzles. Simple template. Powered by Blogger.

Friday 27 September 2013 01:48 AM

Vous aimerez peut-être aussi