Interview Question
Country: United States
What if u start from the middle ? Tree number 3. If you shoot at tree 3 . Then you have 3 posibilities :
-- you killed the monkey
-- the monkey is in the tree 1 or 2. Next shooting will be at tree 2.
-- the monkey is in the tree 4 or 5. Next shooting will be at tree 4.
So the maximum number of times you will have to shoot will be 3. When you start with tree 3 the monkey will be scared to jump through tree number 3.
That would mean you'd have to be able to see the monkey. Then, why not just shoot the tree he's in?
I considered that the monkey is moving all the time, but she gets scared and tries to go far away from the shooting. So if u see it in tree 2 and shoot tree 2 she can move to 1 or 3 in that time (so she gets away). I tried to narrow her options.
My understanding is that the monkey moves at the same time when you shoot --- namely, you "name" the tree you want to shoot, then the monkey moves at random. One confusion for me is that you did not specify whether the monkey can stay still or it *has* to move each time I shoot --- the second case is easier.
2nd case)
You shoot at the side where there are more trees, for example, if the monkey is at tree 2 you shoot at tree 3, then the monkey can either be killed or move to tree 1, then you shoot at tree 2 to kill it.
1st case)
If the monkey can stand still, you still shoot to the tree next to it. For example, if the monkey is on tree 2 you shoot at tree 3. Then the monkey will have a 1/3 chance to be killed by this shot (we assume this is not a cut scene from Matrix and the monkey cannot see where the bullet goes), and you keep continue doing so, and eventually when the monkey is at tree 1, it will have a 1/2 chance to be killed by each shot.
1. You can not see monkey
2. Monkey has to move either way. if you shot same tree then dead.
3. How we find out which side monkey is ??
Thanks for the clarification, now I am clear and a solution I can think of is the following, and by step I mean if the monkey is not killed by previous attempts.
1) Shoot at 4 twice. Then monkey can only be currently in 1, 2, and 3.
2) Shoot at 3 once. Then monkey can only be currently in 1, 2, and 4.
3) Shoot at 2 once. Then monkey can only be currently in 1, 3, and 5.
4) Shoot at 4 once. Then monkey can only be in 2.
5) Kill the monkey whatever way you want.
Point 2 fail .. if monkey at 2 . you shot once at 3. monkey can jump to 3.so after once shot at 3 monkey can be at 3 also
If you move to the next one every time, the oddness between you and the monkey doesn't change, so if you miss the monkey in one traversal, the number of trees between you and the monkey must be even(like you are shoting at#1 while monkey is on tree #2). So if one pass fail, shot at the same tree and change the number of trees between you and monkey to odd, do one more pass and you can't miss it
- Anonymous February 08, 2013