Amazon Interview Question
Country: India
From my understanding of the question, if w and z are the lengths of the sides of the rectangle, the probability should be: 2/((w+1)*(z+1)), given that (x,y) can only be integer co-ordinates.
The idea behind this is simple. The total no. of integral co-ordinates in a rectangle of w,z dimensions are (w+1)*(z+1), including the end-points. Now, the guy can only fall of the island if hes on any one of those 4 points, and makes 2 wrong directions (for eg. west and north at the top left point) at each of these 4 points.
Thus, number of deathly moves= 4*2=8
Total number of possible moves= (w+1)*(z+1)*4, since at each point i can move in 4 directions.
Thus, probability of the guy dying is: 2/((w+1)*(z+1)).
I don't quite understand your question, can you elaborate a little bit?
- Vincent August 09, 2012