Back
Close

Get the distance

Statement

 Goal

The object of this game is to get the euclidean distance between the two points: A and B on a plane.

The plane is a rectangle of width W and height H. It containes exclusively : "-" (representing a empty case), "A" and "B".
Input
Line 1 : Two integer W and H representing the Width and Height of the plane.
H next lines : W chars containing either a "-" (empty case), a "A" (the first point) or a "B" (the second point).
Output
Line 1 : An integer for the rounded euclidean distance between A and B
Constraints
3 ≤ W ≤ 100
3 ≤ H ≤ 100
The distance between the two points must be rounded to the unit
Example
Input
7 5
-------
--A----
-------
----B--
-------
Output
3

Game modes
Fastest, Shortest, Reverse

Test cases
Test 1 Test
Input
7 5 ------- --A---- ------- ----B-- -------
Output
3

Validator 1 Validator
Input
7 5 ------- --A---- ----B-- ------- -------
Output
2

Test 2 Test
Input
10 10 ---------- --A------- ---------- ---------- ---------- ---------- ---------- ------B--- ---------- ----------
Output
7

Validator 2 Validator
Input
10 10 ---------- --A------- ---------- ---------- ---------- ---------- -----B---- ---------- ---------- ----------
Output
6

Test 3 Test
Input
5 3 ----- ----- -A--B
Output
3

Validator 3 Validator
Input
5 3 ----- ----- -A-B-
Output
2

Test 4 Test
Input
3 7 -A- --- --- --- -B- --- ---
Output
4

Validator 4 Validator
Input
3 7 -A- --- --- --- --- -B- ---
Output
5

Solution language

Solution

Stub generator input