 Feature Articles
 CodeSOD
 Error'd
 Forums

Other Articles
 Random Article
 Other Series
 Alex's Soapbox
 Announcements
 Best of…
 Best of Email
 Best of the Sidebar
 Bring Your Own Code
 Coded Smorgasbord
 Mandatory Fun Day
 Off Topic
 Representative Line
 News Roundup
 Editor's Soapbox
 Software on the Rocks
 Souvenir Potpourri
 Sponsor Post
 Tales from the Interview
 The Daily WTF: Live
 Virtudyne
Admin
Three players enter a room and a red or blue hat is placed on each person's head. The color of each hat is determined by a coin toss, with the outcome of one coin toss having no effect on the others. Each person can see the other players' hats but not his own.
No communication of any sort is allowed, except for an initial strategy session before the game begins. Once they have had a chance to look at the other hats, the players must simultaneously guess the color of their own hats or pass. The group shares a hypothetical $3 million prize if at least one player guesses correctly and no players guess incorrectly.
What strategy would you use?
Admin
Quick. Given eight quarters  one weighing more or less than the rest  and a balance scale, if you were faced with the task of figuring out which was the odd coin out using the fewest weighings possible, what would you do?
Obviously, I pocket the quarters and leave this stupid interview, giving me enough change to buy a Coke and pay the highway toll on the way to my next (hopefully better) job interview.
Admin
Bit of an ax to grind, much? The WTF is good (a proper answer to a rather silly question), but the general assertion that brainteasers are worthless is silly. Obviously, there will be some people who suck at brainteasers who are great programmers, just as there are some people who flunked out of college who are great programmers, but it's still a valid item of interest. Anything that measures lateral thinking and makes interviews with soulless corporations a little more fun is a good thing in my book.
Admin
Everyone should guess the same color. Statistically, at least one hat would be that color in a group of 3 or more.
captcha: wigwam Although flim flam is more appropriate for the topic
Admin
Did M$ start doing this after Google had their "IQ Test" job applications? Or was M$ actually an innovator? ;)
Admin
Grandpa's puzzle sounds like a trick. The color of your hat is independent from the color of the other hats, so seeing the other hats gives you no information. It's possible that order of guessing / passing could be used to offer information, but that's been ruled out as well by the fact that everyone has to go simultaneously with no communication. So, basically, you've been given useless information and are stuck with no better than a guess. Pick one person and have them guess wildly while the others pass, you have a 50% shot.
Admin
You have a 3 litre jug and a 5 litre jug. How do you get exactly 4 litres into the 5 litre jug?
Why are manhole covers usually round?
You've got a chicken, a fox, and a bag of grain on one side of the river, and a boat that holds you and one of the chicken/fox/grain. If the fox is left alone with the chicken, he'll eat it. If the chicken is left alone with the grain, he'll eat it. How do you get all across the river so that nobody/nothing gets eaten.
Hat problem  make the strategy be: The person who sees two other people with the same colour hat calls out the opposite colour. He's got a 3/4 chance in being right. There is a 1/4 chance that they are all the same colour, in which case they'll all call out the (wrong) opposite colour.
Admin
The bike for a blind person is relatively easy. Its the bike for their 'seeingeye' dog that is a problem. And that makes it just like software design  the user is the blind person and the 'seeingeye' dog is the user interface.
Admin
I actually saw a good discussion of this one, and how that particular example can be used to guage programming skills. Correct solution was to do a binary sort on on. Put 4 coins on each side of the scale, discard the lighter half, weigh the remaining 4, then weigh the remaining two.....
Course the person who answers that correctly probably just heard it before. Nobody thinks about weighing quarters that fast.
Admin
Obviously, the three gather in a triangle, everyone guesses the hat color of the person to the right, and then every passes their hat to the person to the left and puts on the hat they received from the person to their right. So they all guessed correctly what color hat they are wearing.
Admin
Well... what are the possible outcomes for the hat problem 000 001 010 011 100 101 110 111
You see that 6 out of the 8 cases have two people with one color and one person with the other. If you bet on that, just guess the opposite color if the other two are the same color. Otherwise don't answer.
Of all of the guesses, you'll be right 50% of the time, but 50% of those wrong guesses will be on the same losing situation (3 wrong guesses each in the 000/111 cases). You'll win 75% of the time.
Admin
One problem is that these brain teasers do not test lateral thinking or problem solving skills. They test whether someone has read the same book of brain teasers. If the interviewer were inventing completely original brainteasers, they might possibly show an aptitude for original thought (but more likely the luck to identify some unusual trick having no application outside the specific brain teaser), but I sincerely doubt anyone is doing so. Instead, they pull a bunch from a favorite source. Those who recognize them and can put on a good show of pretending they are solving them for the first time look like geniuses. Those who do not, may or may not figure out the right trick fast enough to impress the interview. Not a terribly useful test.
Admin
First, shoot the fox...
Admin
You people, who think that one person should make a 50% guess at the hat color, fail at probability (or learned it from Marilyn vos Savant). The correct strategy is for each person who sees the others wearing the same color hat to guess the opposite color, and for those that see one of each hat on the other heads to pass. This has more than a 50% chance of getting a winning condition.
Admin
Oops, I guess I should proofread after editing. That last paragraph should read.
Of all of the guesses, you'll be right 50% of the time, but 50% of those guesses will be on the same losing situation (3 wrong guesses each in the 000/111 cases). You'll win 75% of the time.
Admin
I can hold exactly 1/4 liter in my mouth, so first I fill the 3 liter jug, transfer it to the five, then I add 4 mouthfuls to the 5 liter.
Because the manholes are round. They wouldn't fit otherwise.
Feed the grain to the chicken, then feed the chicken to the fox. Take the fox over, then induce vomiting on each animal in reverse order. (captcha = yummy)Admin
And yet the solution you cited is less than optimal. Does it make you a bad programmer that you did not recognize that? Probably not. It just means you never had someone goad you on asking if you can think of a better way. That is the reason these brain teasers are at best tangentially related to programming skill.
Admin
If a player sees two hats of the same color, guess the other color. Otherwise, pass.
In 6 out of 8 possible hattings this will give one correct answer and 2 passes, hence a win. I believe this is the best option, but to prove it is best is of course a whole lot harder.
Admin
I agree that shooting the fox makes perfect sense. No one is going to eat it, and according to the question, that is the desired outcome.
Now if had asked that they all arrive alive, that's another matter.
Admin
And you'd all lose. So even though you didn't read/understand the question and got the wrong answer...
The question is, are you a good programmer?
Admin
The hat one is easy. Just call out the colour of the hat to your left ( or right, as long as everyone picks the same direction ). The chance of having two hats in sequence in this problem is 100%.
Admin
Seeing other people's hat help you in absolute, despite what you think. Of course, chance your hat is blue, considering you see other's hat as red is 1/2, but you can play with dynamically choosing which one respond to optimize result after hats are given:
Given that everyone get an hat. Probabilibty everyone have same hat: 2/8 (1/8 all blue (1/21/21/2), 1/8(same) all red) Probability 2 same color hats and 1 different: 6/8 (there is no other combinaison left).
Let's play with those 6/8, instruction is, "if you see 2 hat of same color, you guess your own is of opposite color. Otherwise you pass". That way, if we are in this 6/8 case, you are 100% sure to win (the only one with a different hat will respond), in the other 2/8 case, everyone pass and it's a lost.
As a result, with this strategy, before entering room you have 75% for your group to win.
So when do i get my 75% of the price?
To guy that suggested to use the pass as information, it's impossible, everyone have to tell at same time (see question).
Admin
Not really. Some of the tests actually have direct relevance to programming. Yes, the weighing an airplane is silly. But the hats/marbles/coins problems usually are just real world implementations of commonly used algorithms. They are mostly searches, sorts and error correction
Admin
Admin
Fill the 5 litre jug. Pour from the 5L jug into the 3L jug till it's full. Empty the 3L jug. Pour the remaining 2L from the 5L jug into the 3L jug. Refill the 5L jug. Fill up the 3L jug (i.e. 2 already in there, 1 from the 5L). There is 4L left in the 5L jug. QED.
Admin
The best solution to any such puzzle is usually "look up the answer", or at the very least look up the answers to similar problems and see if they can put you on the right track.
It's an important and oftenoverlooked skill to know when a solution already exists for a problem, and to use that solution instead of reinventing your own. I have doubts that most interviewers appreciate that particular skill enough, though.
Admin
Hat Problem: Why is everyone guessing, thats silly.
There are only two color hats. In the initial strategy session have everyone agree to point at red hats.
Everyone then gets a random hat, hands are raised to point only at members wearing red hats, everyone knows the color they are wearing (either they are being pointed at or they aren't), no guessing required.
This of course assumes that one of the members isn't a complete jackass willing to pass up on his/her portion of $3 million just to see the reactions of the other two members.
Admin
You probably forgot it's forbiddent to make a wrong guess. If you can make wrong guess and only a correct one is sufficient, i would agree with you :)
Admin
Sounds like we need to start a WTFDonation fund, for people like this who can't get a job because WTF grade interviews exist. We can team up and give this guy a couple weeks pay while he finds a good job.
Admin
I have to interview somebody for a position later this week and I was thinking of using that one (not so sure now). You can actually do it quicker by splitting it into 3 groups. The 8 coin thing is deliberately misleading to make you think of splitting into 2 groups, but you should be able to do it with just two weighings if you split into three. Still, I'd give bonus points for using the term "binary sort".
Admin
I was once asked how many watts were in a bolt of ligtning. I even got it right ;)
Admin
Take the chicken across
Go back, pick up the fox, take the fox across and pick up the chicken.
Take the chicken back with you so that its not left alone with the fox. Put the chicken down and pickup the grain
Take the grain across.
Leave the grain with the fox and go back for the chicken.
Admin
I went through this myself back in (mumble), well before Google (or the web) existed. So MS has been using puzzles for a while. The one I got asked had to do with counting the number of set bits in a register in O(#of set bits).
The interviewer gave a few nudges towards a workable answer  the process seemed more intended to expose how the interviewee thinks. It took me a couple of stabs at it to hit on the right approach, and I still got the (coop) job...
I feel it can be useful (though I wouldn't employ it myself), in the right hands. In the wrong hands, it's just a 'have you seen this before' test, a waste of time.
Admin
This would work quite nicely, except for the rule that says the players are not allowed to communicate.
Admin
Wow, seriously, some of you amaze me.
Whilst I originally thought that brain teasers are stupid in job interviews, your answers have provided me some insights into what they could actually be useful for: testing your ability to read, comprehend and follow basic rules and instructions.
Based on many answers so far, a lot of you would fail.
Admin
The problem that I have with these interviews is that you newer know what are you expected to say. Once I had the question with the coins in the interview. Naturally, I first thought of binary search. Then I thought that this is an interview and it should not be so easy. So I thought harder and got the right answer (I would call that being lucky, not smart). So, I have never mentioned the idea about binarysearch. Still, I do not know if I should have mentioned it or not.
Sometimes I feel as it is a game of trying to guess what you are expected to say, not what the real answer is.
Admin
I've been able to just sit back and enjoy this site for awhile now, but this post has forced me to come out and say something:
BEST POST EVER
Admin
umm... take off your hat and look at it? doesn't say you cant... hopes he hasn't missed something
Admin
Not trying comment either way, but here is my experience. I was recruiting students for our Company at a college campus. Now in India, we sometimes pick up graduates who don't have a Computer Science background, but are from very good schools and have a high aptitude, and then train them on our cost to become programmers.
So, aside from testing them on their subject matter, I chose to give a very simple puzzle/teaser alongside. (It's not a regular interviewing practice at my company). The puzzle: http://www.thedailyriddle.com/2007/02/14/tworopes/ "about how to measure 1.5 hours from two ropes which each take an hour to burn, and the burn rate is not even".
This one guy took forever to answer (while if you can figure it out, its a quick answer). So after like an hour, I asked him to give up but he presented me with a solution (based on which I hired him). He actually sat down and proved the solution mathematically and scientifically. He had got the answer immediately, but thought that he needed to test if it holds true scientifically. (I was given equations, and diagrams, and crosssections, etc.)
Oh yeah, he is one of our better performers in the company today.
Admin
The answer to the riddle is irrelevant, really. What you're testing (and want to see) is the method in which the applicant goes about getting to the answer.
Ideally, these aren't riddles, per se, but rather problems that require solving. For instance, asking where survivors are buried isn't going to teach you anything about the applicant, but something that involves doing some math to work out various possibilities is going to give you an idea about how the person approaches a problem.
Really, it's the approach that you're trying to see, not the answer. If someone shouts out the answer immediately, and recites the answer, as memorized, from a book of problems, that's an immediate check in the "no" column for me. On the other hand, if they have a good idea as to how the problem needs to be solved, that's a check in the "yes" column.
In the end you've got about an hour or so to determine certain things about a person: can they code, how do they handle problems under pressure, can they think abstractly, what kind of design acumen do they have, are they the right temperament for the company, and so on. Including things like impossible to get right questions and problems to solve help to expedite the process.
Admin
What about the estimating ones?
How many quarters would it take to equal the height of the empire state building? Then, how many cokes could that buy?
How many toyota camrys are there on the road right now? How many are white?
How many gas stations are there in america?
Admin
Select one person, who will give a predetermined answer. The rest remain silent. You have a 5050 chance of being correct.
Admin
Agreed 100%.
Alex, bravo on the write up for this.
Brain teasers are absolutely worthless in determining value. If I've heard it before, or read the same book as you, I'll get it immediately and be a genius.
As someone who hated brain teasers in school and isn't great at them, I am the one who gets hurt by companies using this kind of interviewing process. I know I'm not the world's greatest programmer but I do think I am a pretty good one with lots left to learn (and I'll always have lots left to learn). I think I would add value to a company. The fact that I can't solve a brain teaser means that I won't have a chance to prove that.
I am currently employed but having been through lots of interviews a few years ago, this really irritated me.
Captcha: Burned. That's pretty fitting.
Admin
Other possible solutions:
Of course there is the classical solution but i don't like it
Admin
Unless the interviewer is attempting to determine if you know a better sort than binary sort.
Admin
Admin
So someone who has a very good idea about how to go about solving the problem and happens to already know the answer anyway is going to get 'an immediate check in the "no" column".
Smart...
Admin
Agree beforehand to shout out the answer only if both the other hats are the same color. Should only fail when the three hats are the same color, which should only be 2 out of 8 possible combinations. Thus, my odds at winning are 75%.
Admin
Interview for a human ressource:
You ask a teaser to a candidate, he give you a better answer that what is in you list of accepted answer. He did great at rest of interview. Probably the best candidate of today, but you still have 2 candidates to interview. You don't comment on his answer, the interview is nearly over. However, the candidate says it's now or never. When he quit the room, if there is no contract for him, he will never come back here. He also says he won't wait for more than 10 minutes, it's enough to make an offer. What do you do?
A) You start to negociate term end ensure him he will be accepted with a very good salary
B) You ask him to wait while you get to the boss for a contract. During this time you try to quickly test 2 remaining candidates
C) You let him go, there are still 2 other candidates
D) You report to you boss about it and ask his opinion about it
Admin