Microsoft Interview Puzzles
-
A king has a daughter and wants to choose the man she will marry. There are three suitors from whom to choose, a Knight, a Knave, and a Commoner. The king wants to avoid choosing the Commoner as the bridegroom, but he does not know which man is which. All the king knows is that the Knight always speaks the truth, the Knave always lies, and the Commoner can do either. The king will ask each man one yes/no question, and will then choose who gets to marry the princess. What question should the king ask and how should he choose the bridegroom?
A followup question:
Suppose the three suitors know each other (an assumption that’s not needed in the original problem). Then find a new strategy for the king where the king only needs to ask a question of any two of the three suitors in order to pick the bridegroom.
View SolutionSubmit Solution- 1,611.8K views
- 1 answers
- 0 votes
-
In this problem, you and a partner are to come up with a scheme for communicating the value of a hidden card. The game is played as follows:
- Your partner is sent out of the room.
- A dealer hands you 5 cards from a standard 52 card deck.
- You look at the cards, and hand them back to the dealer, one by one, in whatever order you choose.
- The dealer takes the first card that you hand her and places it, face up, in a spot labeled “0”‘. The next three cards that you hand her, she places, similarly, in spots labeled “1”, “2”, and “3”. The last card that you hand her goes, face down, in a spot labeled “hidden”. (While you control the order of the cards, you have no control over their orientations, sitting in their spots; so you can’t use orientation to transmit information to your partner.)
- Your partner enters the room, looks at the four face-up cards and the spots in which they lie and, from that information (and your previously-agreed-upon game plan), determines the suit and value of the hidden card.
Question: What is the foolproof scheme that you and your partner settled on ahead of time?
As a follow-up question, consider the same problem but with a 124-card deck.
View SolutionSubmit Solution- 1,610.3K views
- 1 answers
- 0 votes
-
You’re an electrician working at a mountain. There are N wires running from one side of the mountain to the other. The problem is that the wires are not labeled, so you just see N wire ends on each side of the mountain. Your job is to match these ends (say, by labeling the two ends of each
wire in the same way).In order to figure out the matching, you can twist together wire ends, thus electrically connecting the wires. You can twist as many wire ends as you want, into as many clusters as you want, at the side of the mountain where you happen to be at the time. You can also untwist the wire ends at the side of the mountain where you’re at. You are equipped with an Ohm meter, which lets you test the connectivity of any pair of wires. (Actually, it’s an abstract Ohm meter, in that it only tells you whether or not two things are connected, not the exact resistance.)
You are not charged [no pun intended] for twisting, untwisting, and using the Ohm meter. You are only charged for each helicopter ride you make from one side of the mountain to the other. What is the best way to match the wires? (Oh, N>2, for there is no solution when N=2.)
View SolutionSubmit Solution- 1,608.4K views
- 1 answers
- 0 votes
-
Given N points randomly distributed around the circumference of a circle, what is the probability that all N points lie on the same semi-circle?
View SolutionSubmit Solution- 1,607.7K views
- 1 answers
- 0 votes