• Hey Guest. Check out your NeoGAF Wrapped 2025 results here!

I was asked this analytical question in interview (NO GOOGLING)

Status
Not open for further replies.
here's one more, not sure I'll stay up to check on the results, but if you've never heard it before it's a fun one!

A doctor lives in a mansion along with 3 sons and a butler.
One day the butler inquires about the ages of the sons.
The doctor answers: "I'll tell you in the form of a riddle.
the product of their ages is 36, and the sum is the number of the house across the street."

The butler thinks for a moment, then says: "I need more information...", to which the doctor replies: "you're right, the eldest plays the piano."

The butler then figures it out.

Find the ages.

I think these are the possible choices:

2 3 6
6 6 1
36 1 1
2 2 9
2 1 18
3 3 4
3 1 12
4 1 9

If you add them, 6 6 1 and 2 2 9 both add up to the same number (13) so that's why the Butler asked for more info. Since there is only one oldest son it must be 9 2 2.
 

This is a very old riddle.

The factors of 36 are 2, 2, 3 and 3. It is also divisible by 1 and 36. Sons could be:

1, 1, and 36 (total is 38)
1, 2, and 18 (total is 21)
1, 3, and 12 (total is 16)
1, 6, and 6 (total is 13)
2, 2, and 9 (total is 13)
2, 3, and 6 (total is 11)
3, 3, and 4 (total is 10)

Knowing the total didn't let the butler solve the riddle, so the answer must share a total with another possible answer. That means the total must be 13.

The father then mentions that there is an "eldest" son. Therefore the 1, 6 and 6 answer can't be correct because there are two eldest sons. (At least, that's the argument). Therefore the sons must be 2, 2, and 9.

Not my favorite problem because you kind of have to write out the math and I think the "eldest son plays the violin" thing is a little weak.
It's perfectly possible for two sons to be 6 while one is clearly the oldest, albeit kind of intense.
 
here's one more, not sure I'll stay up to check on the results, but if you've never heard it before it's a fun one!

A doctor lives in a mansion along with 3 sons and a butler.
One day the butler inquires about the ages of the sons.
The doctor answers: "I'll tell you in the form of a riddle.
the product of their ages is 36, and the sum is the number of the house across the street."

The butler thinks for a moment, then says: "I need more information...", to which the doctor replies: "you're right, the eldest plays the piano."

The butler then figures it out.

Find the ages.

Well, I factor 36 and get 3, 3, 2, 2. So there are only a limited number of possibilities for integer ages. The sons can be 18-2-1, 12-3-1, 9-4-1, 9-2-2, 6-6-1, or 6-3-2.

The sums of the ages above are 21, 16, 14, 13, 13, and 11.

The last piece of information is saying that the oldest is not very young. Also important, it's saying that it's a necessary piece of information. This means that the only two possibilities are the combinations that had the same sum, and I go with the older one.

They're 9-2-2.

Edit: Oh, I see what the "eldest" thing was supposed to be doing now. I figured it was that six year olds can't do stuff.
 
here's one more, not sure I'll stay up to check on the results, but if you've never heard it before it's a fun one!

A doctor lives in a mansion along with 3 sons and a butler.
One day the butler inquires about the ages of the sons.
The doctor answers: "I'll tell you in the form of a riddle.
the product of their ages is 36, and the sum is the number of the house across the street."

The butler thinks for a moment, then says: "I need more information...", to which the doctor replies: "you're right, the eldest plays the piano."

The butler then figures it out.

Find the ages.

the possible ages would be 4 3 3/ 6 3 2/ 9 2 2 Edit: forgot about these possibilities 18 1 2 / 12 3 1 /9 4 1/ 6 6 1 / 32 1 1. It is not safe to assume no twins, and 4 is certainly young enough to start playing the piano. the sum is not useful information without knowing the number from across the street. In short I don't know the answer.
 
Psssh, typical nonsense response from someone who doesn't know what they're talking about. I interviewed someone once and totally asked them how many ping-pong balls could fit in a 747.

I will say the best/hardest interview I ever had to survive was a panel interview where they asked me just one question: "We've put you in charge of a project to build a satellite and putting it into space. What do you do?"

That was rough.
 
I will say the best/hardest interview I ever had to survive was a panel interview where they asked me just one question: "We've put you in charge of a project to build a satellite and putting it into space. What do you do?"

That was rough.

What a stupid question unless you were applying for a satellite engineer position.
 
It's a just another generalized problem solving question I think. It's asking you how you would go about solving a problem you're completely unprepared for.
 
What a stupid question unless you were applying for a satellite engineer position.

Actually I thought it was brilliant. Takes you out of your depth and forces you to think things through and communicate with the panel because there's no way you know enough to start formulating an answer. It took me two hours.
 
I didn't want to brute force it :(

Yeah, that's why I don't like this particular one as an interview question. I guess it can test if you're willing to actually roll up your sleeves and write shit out if there's no other way, but I dunno.
 
If the weight machine is a scale, hold onto 3 balls and put 3 balls onto one scale and 3 on the other. If the weight is equal on both ends, then remove those and weigh two balls from the remaining 3 in your hand. If they are equal, then you are holding the lightest ball.

If at any time one side is heavier than the other, then the lighter ball is obviously in 1 of the 3 balls you are weighing. Now just weigh two balls and see which one is the lightest and that is your ball.

Edit: Super late, lol. Oh well.
 
well done everyone who solved it!
took me an hour when my eighth grade physics teacher first asked it!

I didn't want to brute force it :(

part of the complexity here is that it's a multi-step solution, and only one step is "brute force", so to speak.

the possible ages would be 4 3 3/ 6 3 2/ 9 2 2 Edit: forgot about these possibilities 18 1 2 / 12 3 1 /9 4 1/ 6 6 1 / 32 1 1. It is not safe to assume no twins, and 4 is certainly young enough to start playing the piano. the sum is not useful information without knowing the number from across the street. In short I don't know the answer.

this is the step I've seen stump a lot of people, realizing the sum in itself isn't useful, but the fact that it wasn't enough is useful!

Yeah, that's why I don't like this particular one as an interview question. I guess it can test if you're willing to actually roll up your sleeves and write shit out if there's no other way, but I dunno.

Is the one with the 12 weights solvable without rolling up your sleeves? I mean I had a hunch it would work that way, but I wouldn't be able to be sure without writing it all down..
 
here's one more, not sure I'll stay up to check on the results, but if you've never heard it before it's a fun one!

A doctor lives in a mansion along with 3 sons and a butler.
One day the butler inquires about the ages of the sons.
The doctor answers: "I'll tell you in the form of a riddle.
the product of their ages is 36, and the sum is the number of the house across the street."

The butler thinks for a moment, then says: "I need more information...", to which the doctor replies: "you're right, the eldest plays the piano."

The butler then figures it out.

Find the ages.

so I guess we have to use the information that nobody uses 13 for a house number and you have to be older than 6 years old to play piano.
 
Actually I thought it was brilliant. Takes you out of your depth and forces you to think things through and communicate with the panel because there's no way you know enough to start formulating an answer.

So it wasn't for an aerospace management position? It kinda seems like the obvious answer is "immediately ask to be reassigned because I shouldn't be trusted with that kind of budget for something I have no experience with, and if you insist on keeping me around anyway my first step would be to short as much of your stock as I can get my hands on".
 
I played the piano before I was 5 so that doesn't work.

For spaceship mission:
1) Read up on satellite missions on Wikipedia
2) Get in touch with NASA
3) Formulate a basic plan for each phase of a satellite mission: planning, funding, construction, transportation, storage and the launch itself.
4) Tackle each phase one at a time, starting with a cost analysis for each, going on to hiring then the work proper
5) Look into possible contracting companies that can do your work for you
 
I will say the best/hardest interview I ever had to survive was a panel interview where they asked me just one question: "We've put you in charge of a project to build a satellite and putting it into space. What do you do?"

That was rough.

Easy answer, put together a team that has successfully put a satellite in space and make sure they are doing their jobs.
 
well done everyone who solved it!
took me an hour when my eighth grade physics teacher first asked it!



part of the complexity here is that it's a multi-step solution, and only one step is "brute force", so to speak.



this is the step I've seen stump a lot of people, realizing the sum in itself isn't useful, but the fact that it wasn't enough is useful!



Is the one with the 12 weights solvable without rolling up your sleeves? I mean I had a hunch it would work that way, but I wouldn't be able to be sure without writing it all down..

yeah once I realized I forgot to use 1 as product I realized it was useful but I still assert there is not enough information.
 
Suppose you have 9 balls and one of the balls is lighter in weight than the others. You also have a simple weight machine. You get two tries to use the machine and your goal is to find the lighter ball.

3 groups of 3 balls each, weigh two of them , if they are even then the light ball is in the third group
otherwise the light ball is in the light group.

measure 2 balls from the group containing the light ball, if they are even the light ball is the unmeasured ball, if not then the light ball is the one measured to be lighter.
 
here's one more, not sure I'll stay up to check on the results, but if you've never heard it before it's a fun one!

A doctor lives in a mansion along with 3 sons and a butler.
One day the butler inquires about the ages of the sons.
The doctor answers: "I'll tell you in the form of a riddle.
the product of their ages is 36, and the sum is the number of the house across the street."

The butler thinks for a moment, then says: "I need more information...", to which the doctor replies: "you're right, the eldest plays the piano."

The butler then figures it out.

Find the ages.

BTW, I don't know why I got this mental image that the doctor is female and butler has been screwing her.
 
Suppose you have 9 balls and one of the balls is lighter in weight than the others. You also have a simple weight machine. You get two tries to use the machine and your goal is to find the lighter ball.

I've seen that before, but I don't remember the answer. I would take an honest stab at it, but I would also mention that it may be an unintuitive question but it is not a particularly good interview question and it would make me less likely to work there.

wait, crap, this is easy.

weigh three balls vs another three. If they're equal, the third group is the one with the lighter ball, otherwise one of the two groups is. Now weigh two balls out of the group of three you identified in the first weighting, with similar logic. -- er yeah, like what Yofaycesux and Commander Jameson and probably others have already said.

I still stand by my claim that this is a bad interview question. There isn't that much interesting thinking that gets someone from the question to the answer, which means it doesn't tell very much about the candidates. And therefore, it suggests that the hiring organization doesn't know how to look for good candidates and may in fact have a bunch of bad eggs (technically unsound, poor team players, etc).

I get this pretty much every interview.
And this is the other reason it's a bad interview question: because interview veterans will have remembered this.

I guess it's kind of interesting insofar as it suggests people who remember it or figure it out on the spot know about binary search type methods, but that seems like a reach to me.

At least FizzBuzz is some kind of useful filter.

Psssh, typical nonsense response from someone who doesn't know what they're talking about. I interviewed someone once and totally asked them how many ping-pong balls could fit in a 747.
I disagree. The estimate question you posed is a more interesting question than the one posed in the OP, and it worries me that you seem to think they're equally good as interview questions. I think this ping pong ball estimation game gives a few more chances to go on the right track or wrong track and therefore has more ways to tell me if a candidate is a good one or not.

Huh? Maybe I'm not understanding your post, but it sounds like you're saying the problem is that you can't judge someone's ability to think under pressure when they're in an interview because that would be asking them to think under pressure.
The number of days on the job (any job) I've had where I had to think under that much time pressure - and without recourse to references like books or internet - have probably been zero. Just what kind of software development is this? These kinds of 'simulated pressure' aren't good simulations for what you're actually interested in finding out about the candidate.

A game is played between two players on a perfectly round board. Each player has a limitless supply of identical game pieces (think: checkers pieces), in one particular color. Lets say player 1 is white and player 2 is black.

The object of the game is to be the last player to place a piece on the board, or in other words you lose if there is no more room on the board for a piece.

Initially the board is empty, and players take turns placing one piece anywhere on the board.

Having only this information, construct a strategy to win every time. Does this strategy dictate you be given the first turn or does it not matter?
This is actually kind of interesting. Not a full solution, but: I don't think it matters that the board is round though, as long as it's a convex shape. But for simplicity's sake, let's assume the board is the same shape as the pieces and that a piece partially off the board is in an illegal position. Induct forwards from the degenerate cases: (1) the board accommodates exactly one piece, (2) the board accommodates exactly two pieces (in which case the first player actually is guaranteed to win so long as they place their piece to _not_ optimally pack the board, (3) the board accommodates exactly three pieces. The first player should be able to take enough space by eating the center to also be the last player. Basically, a piece controls space around it too. Upon further thought, I think this might be related to a Voronoi diagram drawn inside a circle, with seed points generated by the centers of the pieces in an optimal packing of the pieces?

So I imagine the solution is to generate such a diagram, then count number of segments, then figure out if it's even or odd and therefore whether you should play first or second. Or yeah, what 1138 said.

Actually, Haly's works too and is much more elegant.

Ever notice how any thread anywhere about programming interview questions becomes a competition? =)
 
so I guess we have to use the information that nobody uses 13 for a house number and you have to be older than 6 years old to play piano.

no on both counts.

the 13 is important only because the butler who knows the number of the house still didn't have sufficient information, therefore there is a sum of products of 36 that shows up more than once. the fact that it happens to be 13 is irrelevant, as long as it's the only sum that isn't unique.

The part about the eldest playing the piano is meant to disqualify 6,6,1 because since we are dealing with integer solutions, there has to be a single maximum to count as the eldest.

I played the piano before I was 5 so that doesn't work.

read the above spoiler.

edit:
people sometimes object to disqualifying 6,6,1 based on this, but if you think about it once you've agreed to work only with factors of 36 you've also agreed that there is no "first twin".
 
Weighing #1:
3 balls vs 3 other balls.

If they don't weigh the same, the lighter ball is in the 3 balls that weigh less.
If they do weigh the same, the lighter ball is in the 3 balls you didn't weigh.

Weighing #2:
1 ball from the lighter set of 3 vs 1 other ball from the lighter set of 3.

If they don't weigh the same, the lighter ball is the ball that weighs less.
If they do weigh the same, the lighter ball is the ball you didn't weigh.

EZ EZ EZ
 
Is the one with the 12 weights solvable without rolling up your sleeves? I mean I had a hunch it would work that way, but I wouldn't be able to be sure without writing it all down..

I doubt it. I hate that problem too specifically because I have seen it so many times and can never remember the answer.
 
read the spoiler.

Yeah I know. The point of mentioning the "piano" is to distract you from "eldest". Which, I guess, tests whether you can tell what a client means and not what they're saying.
 
Suppose you have 9 balls and one of the balls is lighter in weight than the others. You also have a simple weight machine. You get two tries to use the machine and your goal is to find the lighter ball.

How large is the scale on the weight machine?

I would put all balls on the machine at once and gradually remove them one by one until I came across the one that removed less weight than the others.
 
I doubt it. I hate that problem too specifically because I have seen it so many times and can never remember the answer.

it's really clever, and you don't have to remember it in order to reconstruct it, if you understand the trick of using a 1-2 split along with adding "standard" weights from the previous try.

Yeah I know. The point of mentioning the "piano" is to distract you from "eldest". Which, I guess, tests whether you can tell what a client means and not what they're saying.

bingo. saying "there's an eldest" would be too obvious..

but personally, I'd never ask that riddle in a job interview, it was just a cool riddle I was reminded of.
 
this actually reminds me of another question I got once.

There is a special egg that has special properties. For one tribe it will cure a plague that has run through the tribe. The plague is fatal and without the egg many of the tribe will die. Another tribe is starving and need the egg to get their crops growing again. Without the egg the second tribe will starve and die. There is only one egg and you have it. What do you do?
 
Ever notice how any thread anywhere about programming interview questions becomes a competition? =)

Same is true of any "riddle" thread.
this actually reminds me of another question I got once.

There is a special egg that has special properties. For one tribe it will cure a plague that has run through the tribe. The plague is fatal and without the egg many of the tribe will die. Another tribe is starving and need the egg to get their crops growing again. Without the egg the second tribe will starve and die. There is only one egg and you have it. What do you do?

Hold an auction.
 
this actually reminds me of another question I got once.

There is a special egg that has special properties. For one tribe it will cure a plague that has run through the tribe. The plague is fatal and without the egg many of the tribe will die. Another tribe is starving and need the egg to get their crops growing again. Without the egg the second tribe will starve and die. There is only one egg and you have it. What do you do?

is this a riddle, though?
 
this actually reminds me of another question I got once.

There is a special egg that has special properties. For one tribe it will cure a plague that has run through the tribe. The plague is fatal and without the egg many of the tribe will die. Another tribe is starving and need the egg to get their crops growing again. Without the egg the second tribe will starve and die. There is only one egg and you have it. What do you do?

Eat it sunny side up.
 
this actually reminds me of another question I got once.

There is a special egg that has special properties. For one tribe it will cure a plague that has run through the tribe. The plague is fatal and without the egg many of the tribe will die. Another tribe is starving and need the egg to get their crops growing again. Without the egg the second tribe will starve and die. There is only one egg and you have it. What do you do?

I guess the answer is something silly like: hatch the egg into a chicken and have it lay more special eggs?
 
Code:
int GetSetBits(int test)
{
        int count = 0;
	if (test < 0)
	{
		test *= -1;
                count++;
	}

	int difference = Int32.MaxValue - test;
        binary(difference, count)
	return count;
}

void binary(int number, int& count) 
{
	int remainder;

	if(number <= 1) 
	{
		return;
	}

	remainder = number%2;
	count += remainder;
	binary(number >> 1, count);    
}

Without going through the details of your code, the actual code to get the number of set bits in an integer would not take these many lines and multiple functions. You just keep "and"'ing the number with 1 and "shifting" the number and increment the count with the result of the "and" (or a variation of the scheme. I think there are ways to get out after the last set bit).

Everybody will get that part (or so I hope). My follow up (open ended) question however is asking the candidate to improve on the performance of the code.
 
this actually reminds me of another question I got once.

There is a special egg that has special properties. For one tribe it will cure a plague that has run through the tribe. The plague is fatal and without the egg many of the tribe will die. Another tribe is starving and need the egg to get their crops growing again. Without the egg the second tribe will starve and die. There is only one egg and you have it. What do you do?

Jesus, what kind of jobs do you interview for?

I feel like I want to ask whether either tribe actually needs to consume the egg to get the benefits. Also maybe if I belong to one of these tribes in this story.
 
Actually I thought it was brilliant. Takes you out of your depth and forces you to think things through and communicate with the panel because there's no way you know enough to start formulating an answer. It took me two hours.

this actually reminds me of another question I got once.

There is a special egg that has special properties. For one tribe it will cure a plague that has run through the tribe. The plague is fatal and without the egg many of the tribe will die. Another tribe is starving and need the egg to get their crops growing again. Without the egg the second tribe will starve and die. There is only one egg and you have it. What do you do?

These two questions seem far easier than everything else that has been asked in here. It's not that they're easy problems to solve, but they're pretty free form I guess. There is no one right answer to them, so you can kinda work your way through them (and talk to the panel about them like you said I suppose).
 
Without going through the details of your code, the actual code to get the number of set bits in an integer would not take these many lines and multiple functions. You just keep "and"'ing the number with 1 and "shifting" the number and increment the count with the result of the "and" (or a variation of the scheme. I think there are ways to get out after the last set bit).

Everybody will get that part (or so I hope). My follow up (open ended) question however is asking the candidate to improve on the performance of the code.

I see. I've never learned bit shifting formally so I don't know these things. I actually hashed something out just to get you to explain to me how to do it properly.

:3
 
I guess the answer is something silly like: hatch the egg into a chicken and have it lay more special eggs?

My thought is that the egg doesn't have to be consumed for the effect only that it has to be owned. So I would convince both tribes to name me as their leader and since I own the egg both tribes will benefit.
 
I disagree. The estimate question you posed is a more interesting question than the one posed in the OP, and it worries me that you seem to think they're equally good as interview questions. I think this ping pong ball estimation game gives a few more chances to go on the right track or wrong track and therefore has more ways to tell me if a candidate is a good one or not.

My response was more about poking at ronito since we were just talking about this yesterday, but... I'm not sure why it worries you. :P [edit: and just in case it wasn't clear, the whole thing was sarcastic. ronito is a smart dude and really knows his shit when it comes to interviews.]

I'm not an expert; I don't have to interview people (outside of "hey Cyan, sit down with this person for half an hour and see if you think you'd work together well") and I haven't had to interview for a job in about a decade. But to me the questions are of a similar class. If you've heard the puzzle before or if you have some idea how to do Fermi estimates, they're not difficult. Otherwise it's a test on thinking aloud. Which I'm not fond of because I don't think aloud well, as I said earlier in the thread. Maybe the ping-pong ball one gives more room for coming up with something, but they don't seem wildly different to me.
 
Jesus, what kind of jobs do you interview for?

I feel like I want to ask whether either tribe actually needs to consume the egg to get the benefits. Also maybe if I belong to one of these tribes in this story.

I'm a consultant. So I guess the answer is "all of them"? I do an awful lot of client interviews. As well as performing interviews for hires

You're close. You're supposed to ask questions to figure out the actual problem. One of the tribes just needs the yolk the other the shell.
 
I will say the best/hardest interview I ever had to survive was a panel interview where they asked me just one question: "We've put you in charge of a project to build a satellite and putting it into space. What do you do?"

That was rough.

Outsource to the Russian space agency.
 
this is the step I've seen stump a lot of people, realizing the sum in itself isn't useful, but the fact that it wasn't enough is useful!

You don't know that it wasn't enough info. The butler could just be dumb.
Furthermore, you don't know that the ages are integers.

If you assume the ages are integers, then these are the following options:

36,1,1 = 38
18,2,1 = 21
12,3,1 = 16
9,4,1 = 14
9,2,2 = 13
6,6,1 = 13
4,3,3 = 10

If you assume that the butler wasn't an idiot, then the options are the ones with identical sums.

9,2,2 = 13
6,6,1 = 13

The "eldest" line isn't supposed to give you information because a 6 year old can't play the piano but a 9 year old can, it's supposed to give you information because it's stating that there IS an eldest.

But since you've already considered the ages as integers, both of the 6 year olds qualify as "the eldest". And you don't even need a twin scenario - they could be born 10 seconds apart, 10 months apart, 2 months apart to different mothers, whatever.

Broken riddle is broken.

You're close. You're supposed to ask questions to figure out the actual problem. One of the tribes just needs the yolk the other the shell.

No, both tribes need to stfu and listen to me.

1) Interbreed to get some genetic diversity so you don't all fall to a simple disease at the same time.
2) Use the dead people to fertilize your crops.
3) Get me some pepper for my fucking scrambled egg!
 
My response was more about poking at ronito since we were just talking about this yesterday, but... I'm not sure why it worries you. :P

I'm not an expert; I don't have to interview people (outside of "hey Cyan, sit down with this person for half an hour and see if you think you'd work together well") and I haven't had to interview for a job in about a decade. But to me the questions are of a similar class. If you've heard the puzzle before or if you have some idea how to do Fermi estimates, they're not difficult. Otherwise it's a test on thinking aloud. Which I'm not fond of because I don't think aloud well, as I said earlier in the thread. Maybe the ping-pong ball one gives more room for coming up with something, but they don't seem wildly different to me.

I feel like my preferred interview question would be more like:

"What was the last project you worked on?"
"Oh, how did you handle X?"
"Wouldn't it be better to do Y instead?"

The way they respond to these questions seems generally more relevant to me. But that might be why I'm not a programmer! And, of course, it's something an HR screen can't be expected to accomplish.
 
Okay GAF,

Lets play a game.

You're stuck in a room with a door that will lock if you exit the room TWICE. Outside of the room, out of sight around a corner there are three lightbulbs next to another door.

In your room there are 3 switches. You don't know which switch controls which bulb. The goal is to turn on the bulbs from left to right to open the door.

How can you figure out what switch goes to which bulb?

The room has no windows. You can not see the bulbs from the doorway. You can leave the room ONLY ONCE to check the bulbs and when you enter and leave the room again you will be locked out of the room with the switches and your death will be slow..with only lightbulbs to eat.
 
Status
Not open for further replies.
Top Bottom