Attack the nearest enemy


Submit solution

Points: 15
Time limit: 8.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Python

Problem Statement

You are developing an Alien Invader Shooting Game. Your spaceship is in a fixed position. Alien ships appear in random locations on the 2D screen. At any point in time, there will be only two alien ships on the screen. Your duty is to find the nearest alien ship to shoot first.

Given the (x,y) coordinates of your spaceship as well as those of the two alien ships, your task is to compute the Manhattan distance between your spaceship and each of those enemy ships and decide the ship to shoot first based on the smallest distance. If the distances are the same, you will shoot enemy ship 1. Otherwise, you will shoot the ships with the shortest distance. Manhattan distance is calculated as |x - x1| + |y - y1| between two points (x,y) and (x1,y1).

Write a Python program to identify the closest enemy ship.

Input

There will be six lines of input. The first two lines are the x and y coordinates of our spaceship. The next two lines are the x and y coordinates of the first enemy ship. The last two lines are the x and y coordinates of the second enemy ship.

Output

If the closest enemy ship is 1 or both of them are at the same distance, the output is 1. Otherwise, the output is 2.

Sample Input1

10

20

15

5

20

20

Sample Output1

2

Sample Input2

0

0

5

5

-5

-5

Sample Output2

1


Comments

There are no comments at the moment.