• 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.
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.

On the topic of silly interview questions, this is the sort of thing I feel is kind of ridiculous.

It's like that problem with
three light switches where the bulbs are in the other room. Framing the question as a riddle triggers certain modes of thinking. There are things you're not allowed to do in riddles. The light bulb one, of course, has to do with accounting for the thermal inertia of a bulb, which is just a ridiculous thing to account for in something that sounds like a logic puzzle.
Asking exactly what each village needs to do with the egg would be the first thing anyone in anything like that situation would actually do, but when posed as a puzzle it's easy to assume that the egg is destroyed (because clearly this is what the asker wants you to think).

Edit: Accidentally spoiled question of the guy who posted just before me.
 
On the topic of silly interview questions, this is the sort of thing I feel is kind of ridiculous.

It's like that problem with
three light switches where the bulbs are in the other room. Framing the question as a riddle triggers certain modes of thinking. There are things you're not allowed to do in riddles. The light bulb one, of course, has to do with accounting for the thermal inertia of a bulb, which is just a ridiculous thing to account for in something that sounds like a logic puzzle.
Asking exactly what each village needs to do with the egg would be the first thing anyone in anything like that situation would actually do, but when posed as a puzzle it's easy to assume that the egg is destroyed (because clearly this is what the asker wants you to think).

Edit: Accidentally spoiled question of the guy who posted just before me.

Right, that's sort of the tricky bit. Look at Mudkips' discussion of the age riddle--it seems totally pedantic since he's ignoring the implied rules of the riddle, but then some of these questions require you to do exactly that to find the answer!
 
It's nice to think the hours I spent reading brainteasers as a kid are now considered developing a marketable skill.
 
So what is the answer to the light bulb question. Turn on each lightbulb one after the other with an hour long break inbetween, then go feel the relative temperature of/surrounding the bulb?
 
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.

Switch 1 on for 10 minutes.
Switch 1 off.
Switch 2 on.
Go outside.
Look at shit. The bulb that is on is switch 2.
Touch shit. The bulb that id warm is switch 1.
The bulb that is off and not warm is switch 3.
Go back in the room and diddle the switches with your newfound knowledge.
Go outside.
Other door is now open.

Die because they are newfangled environmentally friendly bulbs and didn't get hot enough for you to be able to tell.
 
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.

I've already addressed most of these issues, but there are others I haven't.

1) if you're factoring 36 then by definition all ages are integer, in which case eldest implies a singular maximum age, so there is no "older twin".

2) another way to think about this would be to remember that the sum and product are both integers, so while the solutions could technically be non-integers, it becomes less likely. It's even less likely if you understand that no unique solution exists over non-integers..

3) saying the butler could be dumb is kind of like insisting to first try non-integer solutions. It goes against the concept of a riddle, which is "work with what you have, not with what you don't".

But as I said earlier, I'd never use this on a job interview.. It's too easy to make one wrong turn and end up with nothing at all, even if the rest of your reasoning was sound.
 
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 see! Now I also understand what you meant by "communication problem". nice!

Die because they are newfangled environmentally friendly bulbs and didn't get hot enough for you to be able to tell.

LOL

when I was young my dad used a similar trick whenever coming home from work, because he knew my brother and I would watch TV and shut it off when we heard him coming, so he would think we were doing something more productive with our time.

He'd always put his hand on the CRT screen, and if there was lots of static electricity, he'd know we just shut it off a minute ago :P
 
I've already addressed most of these issues, but there are others I haven't.

1) if you're factoring 36 then by definition all ages are integer, in which case eldest implies a singular maximum age, so there is no "older twin".

2) another way to think about this would be to remember that the sum and product are both integers, so while the solutions could technically be non-integers, it becomes less likely. It's even less likely if you understand that no unique solution exists over non-integers..

3) saying the butler could be dumb is kind of like insisting to first try non-integer solutions. It goes against the concept of a riddle, which is "work with what you have, not with what you don't".

Why would I be doing prime factorization on 36? All the problem states is that the product is 36.

No one ever said the sum was an integer.

48 years old, 1.5 years old, .5 years old
Product = 36
Sum = 50

72,1,.5
Product = 36
Sum = 73 1/2 - Still a valid house number

The butler asking for more information doesn't tell you anything for certain unless you assume:
1) The ages are integers.
2) The butler is logical.
3) The man supplying him information isn't trolling his ass by giving him an unsolvable riddle.

You can't assume those three things because then the use of "eldest" is logically broken. If you want me to work with integers then both 6 year olds are "the eldest" just as in a race where 2 people clock in at the same time get the same place, and the person behind them gets 2 places below them (for example, 1st, 1st, 3rd).

Broken riddle.
 
Mudkips is too angry for these problems.
 
I'm curious about how many people are actually able to answer a lot of these riddles/questions correctly during interviews. I think they're neat, but as I said earlier I haven't figured any of them out (Haven't given them much thought though, but I can still see that they're pretty tricky). Been too quick to check the answers in here instead of thinking about them for a while (but that's the thing I guess, you probably don't have "a while" during an interview, so it doesn't really matter).

They're fun once you understand them though :P
 
Right, that's sort of the tricky bit. Look at Mudkips' discussion of the age riddle--it seems totally pedantic since he's ignoring the implied rules of the riddle, but then some of these questions require you to do exactly that to find the answer!

I think that's what marks the clear difference between a "logic puzzle" and a "communication puzzle". The former assumes there's a solution you can work out entirely by yourself, the latter does not.

I think it's actually a good way to distinguish between two very different modes of thought.

On an unrelated matter, why the hell aren't I going to sleep??

edit: really didn't mean to upset you this much Mudkips, I didn't invent the riddle and I completely agree part of what makes it difficult is the fact it requires multiple stages to work out, with different modes of thought at each stage. If you want to analyze it at a strictly logical level you could poke holes in some of the arguments, but that's what I feel separates it from other purely mathematical riddles.

I always appreciated my highschool physics teacher for giving it to us, because it strikes me as more of a "physicist's puzzle" than a "programmers puzzle", in the sense that it's perfectly ok to make unconventional considerations in order to reduce an otherwise unsolvable problem to a solvable one. This is a quality shared by many riddles, but, like the one with the 3 light-bulbs, figuring out which assumptions are ok and which aren't isn't always immediately obvious.

If it were always obvious what tools to use, these would be math problems, not riddles. Part of the challenge here is exercising mental flexibility when coming up with a solution.

When I was in grade school I had an argument with a friend about the classic "cross the river with wolves, sheep and lettuce" riddle. He didn't like the standard solution and argued you could always leave the wolf and sheep together as long as you placed a heavy rock on the wolf so he couldn't move. His reasoning was that you can always find a heavy rock or some other heavy object in your surrounding...

Anyway, here's one more, which I believe you'll find more enjoyable since there is very clear-cut logic behind it:

a group of inmates are each given a lifetime sentence in prison, but before they are locked up separately they are offered a single chance to communicate between them.
the guards present them with the following challenge:

There is a courtyard in the prison with a light that can be switched on or off. Each day the guards randomly select one inmate to go out to the courtyard for a breath of fresh air. Inmates can be chosen as many times as the they are randomly selected, including zero, and there is no communication between them while in prison.

The challenge is to be able to state with absolute certainty that all inmates have been to the courtyard. If successful, they would be released. If unsuccessful they would be executed. (aka you only have one shot at delivering your statement to the guards).

Find the strategy.
 
if you have some idea how to do Fermi estimates...

As a side note, here's a quick example of how I'd solve the ping-pong ball question:

Fermi estimates are largely about making assumptions to keep things simple to calculate. We'll assume a ping-pong ball is a cube 1 inch on each side. Or, to make it even simpler let's call it a tenth of a foot on each side. I don't know how big a 747 is on the inside, but let's pick some round numbers and call it 300 feet long, 20 feet wide, and 10 feet high. That gives a total internal space of 60,000 cubic feet. 1/10 cubed is 1/1000, so 1000 ping-pong balls in a cubic foot, for a result of 60,000,000.

Aaaand just googled it, and apparently the "real" answer is somewhere around 20,000,000. Off by less than an order of magnitude, not bad! I probably overestimated the internal dimensions of the 747.

On an unrelated matter, why the hell aren't I going to sleep??

An insoluble problem...
 
Did not read the thread or google. I am going to make one assumption, that the weight machine is a balance scale.

Put three balls in each side of the scale. If one side is lighter, that's the group the lighter ball is in. If they weigh the same, the lighter ball is in the three you didn't weigh.

Now take the group of three you've determined has the lighter ball. Put one ball on each side of the scale. If one is lighter, that's your ball. If they weigh the same, the ball you didn't weigh is the one.

Now, if the weight machine is a single platform scale, I can't think of how it would be done. In two tries you could maybe narrow the ball down to being in a group of four, but that's about it.
 
Why would I be doing prime factorization on 36? All the problem states is that the product is 36.

No one ever said the sum was an integer.

48 years old, 1.5 years old, .5 years old
Product = 36
Sum = 50

72,1,.5
Product = 36
Sum = 73 1/2 - Still a valid house number

The butler asking for more information doesn't tell you anything for certain unless you assume:
1) The ages are integers.
2) The butler is logical.
3) The man supplying him information isn't trolling his ass by giving him an unsolvable riddle.

You can't assume those three things because then the use of "eldest" is logically broken. If you want me to work with integers then both 6 year olds are "the eldest" just as in a race where 2 people clock in at the same time get the same place, and the person behind them gets 2 places below them (for example, 1st, 1st, 3rd).

Broken riddle.

By your logic the OP's riddle is broken because how do you know you weren't trolled and given a faulty weight machine lolol??
 
Sorry I should be more clear

I meant this

stock-photo-simple-balance-45809926.jpg

That's mass, not weight. HR shit gets fired and I eat what I kill.
 
Here's another one. I never ask this myself because an ok answer is easy to get but the optimal best answer is hard to come by in an stressful one hour interview and I put it in the category of the questions that if the candidate does not know the answer, it is hard to give him credit for his thought process (unlike the other puzzle "10 people with blur/red hat on stair").

You have two identical marbles that would break if released from a certain height or higher and would not break otherwise.

We have a 100 story building and we like to determine which floor is the threshold for breaking the marbles.

Find the threshold floor with the minimum number of tries in worst case scenario.

(obviously one can start with the first floor, drop a marble and if does not break, try the second floor, then the third and so on. The worst case scenario in this approach is 100 tries. we are looking for an approach that takes fewer number of tries in worst case scenario.)

the best I can do is selecting a step size of 10 aka root of the height and trying the first marble then filling in the gap with the second marble. that would give you something like 19 tests or on the order of 2 * root(n) for height n.

I really want to know the optimal answer :l
 
As a side note, here's a quick example of how I'd solve the ping-pong ball question:

Fermi estimates are largely about making assumptions to keep things simple to calculate. We'll assume a ping-pong ball is a cube 1 inch on each side. Or, to make it even simpler let's call it a tenth of a foot on each side. I don't know how big a 747 is on the inside, but let's pick some round numbers and call it 300 feet long, 20 feet wide, and 10 feet high. That gives a total internal space of 60,000 cubic feet. 1/10 cubed is 1/1000, so 1000 ping-pong balls in a cubic foot, for a result of 60,000,000.

Aaaand just googled it, and apparently the "real" answer is somewhere around 20,000,000. Off by less than an order of magnitude, not bad! I probably overestimated the internal dimensions of the 747.



An insoluble problem...

that's basically how I'd approach the ping pong ball question, maybe I'd use different estimates, but that comes down to personal preference. the only thing I'd change would be incorporating the fact that packing balls results in a lot of wasted space, so either I'd take my result and multiply by half or two thirds or some fraction, or I'd do this independently for height, length and width and think about wasted space in each dimension independently.

another important element to remember when dealing with such estimates is to also try to have a rough idea on your margin of error. So for example one may not know that a 747 is 300 feet long, but one could be certain that it was longer than 100 feet and shorter than 500. Then you end up with a neat and tidy formula and all that's left is plugging in your estimates as well as your level of confidence or margin of error, for a more robust result.
 
First time:

3 on one side, 3 on the other

If they are the same weight, the lighter ball is in the 3 leftovers.

Else it is on the one that is on the higher side of the scale.

Second time:

Out of the set of three with the lighter balls do the same as above.

Chose two randomly. If they are the same, the lighter one is the one not on the scale, else it is on the higher side of the scale.

Why you so smart?
 
Anyway, here's one more, which I believe you'll find more enjoyable since there is very clear-cut logic behind it:

a group of inmates are each given a lifetime sentence in prison, but before they are locked up separately they are offered a single chance to communicate between them.
the guards present them with the following challenge:

There is a courtyard in the prison with a light that can be switched on or off. Each day the guards randomly select one inmate to go out to the courtyard for a breath of fresh air. Inmates can be chosen as many times as the they are randomly selected, including zero, and there is no communication between them while in prison.

The challenge is to be able to state with absolute certainty that all inmates have been to the courtyard. If successful, they would be released. If unsuccessful they would be executed. (aka you only have one shot at delivering your statement to the guards).

Find the strategy.

the person that goes out on the first day determines whether all inmates have visited the yard. He changes the state of the light (off if it was on, on if it was off) the first time you visit the yard you change the state of the light then you never change it again. the next time the first inmate is chosen after he wasn't chosen it will either be the same state he left it as, meaning all inmates have visited the yard, or it will be in the other state meaning only one of the others visited the yard.
 
the person that goes out on the first day determines whether all inmates have visited the yard. He changes the state of the light (off if it was on, on if it was off) the first time you visit the yard you change the state of the light then you never change it again. the next time the first inmate is chosen after he wasn't chosen it will either be the same state he left it as, meaning all inmates have visited the yard, or it will be in the other state meaning only one of the others visited the yard.

Uh, won't this fail if an even number of inmates less than the maximum have visited the yard?
 
except for the fact that top tier companies actually do ask this question (or other similar questions to assess your on the spot analytical abilities) and walking out on them would be stupid.

Yes, I would literally walk out of an interview with a top tier company if this happened.

Or I could have been joking.

You didn't pass my interview test. Get out of my office.
 
I

Anyway, here's one more, which I believe you'll find more enjoyable since there is very clear-cut logic behind it:

a group of inmates are each given a lifetime sentence in prison, but before they are locked up separately they are offered a single chance to communicate between them.
the guards present them with the following challenge:

There is a courtyard in the prison with a light that can be switched on or off. Each day the guards randomly select one inmate to go out to the courtyard for a breath of fresh air. Inmates can be chosen as many times as the they are randomly selected, including zero, and there is no communication between them while in prison.

The challenge is to be able to state with absolute certainty that all inmates have been to the courtyard. If successful, they would be released. If unsuccessful they would be executed. (aka you only have one shot at delivering your statement to the guards).

Find the strategy.

Is the light a red herring?
 
I can think of easy solutions, but there are probably faster methods.

The inmates know the number of inmates N and they're all counting days.

They agree to break up their stay into chunks of N days. To make it easy let's suppose there are 7 inmates so that I can just talk about weeks.

On the first day of each week, the inmate who gets chosen turns the light on. If any inmate is sent to the yard twice in a week, he turns the light off on his second trip.

At the beginning of the second and all subsequent weeks, if the light is still on then all inmates visited the yard in the prior week with no repeats.
 
Put 4 on one side and 5 on the other if the side with 4 is heavier the lighter ball in on the 5 side ? I have no idea.

Pack it up this is it

thought about this for like 1 minute:

split into 3 groups, 3 balls each -

weigh 2 of the groups. If they're the same weight you know the ball is in the 3rd group you didn't weigh. If they aren't the same weight then choose the group of balls that lighter.

with the group of the balls containing the weird ball, do the same thing you did above. So, weigh 2 of them and if they're the same weight then it's the ball you didnt weigh. If they're not the same then you know which ball it is from the scale.

was this a programming interview? this is kind of like an abstract recursion problem, with a little bit of "optimizing" since you don't want to waste time weighing groups of balls you don't need to.

Also great great answer.
 
I can think of easy solutions, but there are probably faster methods.

The inmates know the number of inmates N and they're all counting days.

They agree to break up their stay into chunks of N days. To make it easy let's suppose there are 7 inmates so that I can just talk about weeks.

On the first day of each week, the inmate who gets chosen turns the light on. If any inmate is sent to the yard twice in a week, he turns the light off on his second trip.

At the beginning of the second and all subsequent weeks, if the light is still on then all inmates visited the yard in the prior week with no repeats.

Damn, that's clever. Takes forever to return though.
 
I can think of easy solutions, but there are probably faster methods.

The inmates know the number of inmates N and they're all counting days.

They agree to break up their stay into chunks of N days. To make it easy let's suppose there are 7 inmates so that I can just talk about weeks.

On the first day of each week, the inmate who gets chosen turns the light on. If any inmate is sent to the yard twice in a week, he turns the light off on his second trip.

At the beginning of the second and all subsequent weeks, if the light is still on then all inmates visited the yard in the prior week with no repeats.

I see
So take the # of inmates if anyone goes twice shut off the light if the # inmates = # of days and the light is still on they all went

But the guards could troll it and make sure their system will take forever to work out.
 
I can think of easy solutions, but there are probably faster methods.

The inmates know the number of inmates N and they're all counting days.

They agree to break up their stay into chunks of N days. To make it easy let's suppose there are 7 inmates so that I can just talk about weeks.

On the first day of each week, the inmate who gets chosen turns the light on. If any inmate is sent to the yard twice in a week, he turns the light off on his second trip.

At the beginning of the second and all subsequent weeks, if the light is still on then all inmates visited the yard in the prior week with no repeats.

I'm not sure I understand. Lets say there are seven inmates, and on the first six days the same one gets chosen, and on the seventh day a second inmate is chosen.

at the end of this week the light would be on but 5 inmates would have never been taken outside...
 
I'm not sure I understand. Lets say there are seven inmates, and on the first six days the same one gets chosen, and on the seventh day a second inmate is chosen.

at the end of this week the light would be on but 5 inmates would have never been taken outside...

Each inmate knows that the second time they go out in a week, they should turn the light off. If they go out a third time or more in the same week they just leave it off. So in your example the second time inmate 1 goes out he turns the light off, and the third through sixth times, nothing happens.
 
There should be a riddles/logic puzzle OT. Post daily/weekly puzzles or something and use a Google Docs to keep track of score.
 
Oh I see.
So basically this system checks for repeats. If there isn't a repeat in N days given an N amount of prisoners, then it means everyone went.

Wow that is really neat.
 
Each inmate knows that the second time they go out in a week, they should turn the light off. If they go out a third time or more in the same week they just leave it off. So in your example the second time inmate 1 goes out he turns the light off, and the third through sixth times, nothing happens.

this part is fine, but all that the state of the light tells you in this case is that somebody has been out once, not that everybody has been out once.

Oh, I'm sorry, I misunderstood your phrasing. Yes that is the correct answer. I didn't notice I made an omission when telling the riddle, in that it's possible no one goes out on a given day, but then the solution would essentially just be an extension of yours, and take even longer.

well done!

also, as others have noted, the guards could make this take a very long time.
 
this part is fine, but all that the state of the light tells you in this case is that somebody has been out once, not that everybody has been out once.

For the light to turn off after N days, at least one prisoner must've been out twice. What this strategy is doing is gambling on reaching an instance of N days such that the light remains on (so there are no repeats). It's pretty inefficient but it works.
 
this part is fine, but all that the state of the light tells you in this case is that somebody has been out once, not that everybody has been out once.

No, the state of the light
tells you whether someone has been out more than once. Because the time period we're looking at has one day for each inmate, the only way for there to be no second trips over the period is if each inmate goes to the yard exactly once.
 
this part is fine, but all that the state of the light tells you in this case is that somebody has been out once, not that everybody has been out once.

If the light is on at the end of the week, that means seven days have passed with no repeats. Since there are seven inmates in this example, they must all have gone out.

Obviously use a different "week" for a different number of inmates.
 
an alternate solution I came up with was to designate one inmate as the "counter". This is possible because he can be selected at the time of forming the strategy.

the counter and only he resets the light and anybody else merely changes the state on their first time and does nothing otherwise.

it would require for the counter to be selected at least as many times as there are inmates, which is also terribly inefficient, but would work without a duration where they were all selected exactly once.
 
an alternate solution I came up with was to designate one inmate as the "counter". This is possible because he can be selected at the time of forming the strategy.

the counter and only he resets the light and anybody else merely changes the state on their first time and does nothing otherwise.

it would require for the counter to be selected at least as many times as there are inmates, which is also terribly inefficient, but would work without a duration where they were all selected exactly once.

Yeah, that's going to be hugely faster than what I came up with.
 
Status
Not open for further replies.
Top Bottom