Interview Question


Country: -




Comment hidden because of low score. Click to expand.
5
of 7 vote

1 demon 1 human
demon eat human.
2 demon 1 human
nothing happens.
3 demon 1 human
one demon eat the human.
Explanation:
if there are odd number of eaters and one sleeping target, one of the eater(demon) will eat the target(sleeping demon/man).
if eaters are even(>=2) nothing will happen because if he eat the target he will become the target,Now eaters will be odd and according to first case target will be eaten, so nobody of demons want to become target so nobody eat.

So 65+1
one demon eats the sleeping man.
nothing happens after that.

- Anonymous October 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

In the case of 3 demons and 1 man
Why would any demon eat the human, because if it eats it will be the target. Notice that the demons are not sleeping. The demon who eats the man will sleep and will be a target now.

- Swap October 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Although the demon(3rd) which eats the human becomes target, the others can'nt eat this daemon(3rd) because the daemon(2nd or 1st) which eats this daemon(3rd) will become the target for (1st Or 2nd) daemon. So none of the 1st or 2nd daemons will dare to eat the 3rd.

- Swap1 November 25, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

How come Even or Odd cases comes over here ...... If one demon eats the man ........ No other demon will eat that demon ........ for any case where number of demons greater than 2 ....... and in every case the man will be eaten

- Siddhartha April 05, 2013 | Flag
Comment hidden because of low score. Click to expand.
3
of 3 vote

Each demon is waiting for all the other demons to eat the man and fall asleep, and thus no demon ever does. Thread deadlock parable?

- jkunzvt October 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Nothing will happen.All 65 +1 will be alive..
:)

- Ram October 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Infact according to me, either one demon will live or everbody including will live. Lets say 1st demon will eat the man thinking that if he eats the man than no demon will eat this demon, as the second demon will become the target. If all demons will think this way then no demon will stay will alive but one.
In other case lets assume that all demons think the other way round that if it eats and then sleeps, then it will get eaten, so no one will get eaten.

- ishantagarwal1986 October 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Problem says "Demons are very smart, and will always chose to stay alive than risking their life.".

So the most probable answer is that nothing will happen.

- Adrian October 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

+1 to Adrian

- Anonymous January 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

man will be killed.65 demons are alive.

- Anonymous October 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The question doesn't say anything about a demon sleeping after eating another demon. Hence any one of the demons will eat the sleeping man and all 65 demons remain.

- Anonymous February 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Agreed that a demon wont sleep after eating another demon, but if any of the 65 demons ate the sleeping man he will be dead as he knows he will fall asleep after eating the man. Thus no demon eats the man. All 65+1 survive
Amen!

- anon July 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

No man chooses to live in a village which is full of demons......

- Indiresh.D.S June 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just wake up the man dude, problem solved :P

- heehee November 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

One who asked this question would have been a demon.. :)

- s.issac.sam January 18, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More