Question: In python. We have two policemen and one thief. They are standing at random positions in a two dimensional grid. The thief broke into a

In python. We have two policemen and one thief. They are standingat random positions in a two dimensional grid. The thief broke intoa house and triggered a silent alarm, alerting the two police officersIn python.

We have two policemen and one thief. They are standing at random positions in a two dimensional grid. The thief broke into a house and triggered a silent alarm, alerting the two police officers to the location of the break-in. Assume that he is busy stealing and will not be moving. The two policemen start to make their way to the thief. Assume that the Policeman A reaches the thief first, return Policeman A. IF Policeman B reaches the thief first, return Policeman B. If they reach the scene at the same time, the Policemen will be dis-orientated and the thief will be able to escape. In that case return Thief. Assume that the policemen can only move in a Manhatten distance along the grid lines. This means that the distance between two points with p1 at (x1, y1) and p2 at (x2, y2) is | x1 - x2] + [y1 - y2). Do note that |x-y|| means the absolute value of x minus y. Example 1 So if Policeman A is at (3, 4), Policeman B is at (1,6), Thief is at (5,5) The distance from Policeman A to the thief is 3-5 + 14-5| = 3 The distance from Policeman B to the thief is 11-51 + 16-51 = 5 So Policeman A is the answer Example 2 So if Policeman A is at (3, 4), Policeman B is at (6,6), Thief is at (5,5) The distance from Policeman A to the thief is (3-5[ + 14-51 = 3 The distance from Policeman B to the thief is 16-5| + 16-5| = 2 So Policeman B is the answer Input Format Input Format 2 Policeman A X location Policeman A y location 2 Policeman B X location Policeman B y location 2 Thief X location Thief y location Constraints Positive numbers Output Format Policeman A OR Policeman B OR Thief Sample Input 0 2 3 4 2 1 6 2 5 5 Sample Output 0 Sample Output 0 Policeman A Sample Input 1 O NOONWN Sample Output 1 Policeman B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!