Queen Attack
Statement
Goal
A chess board is a square of 8x8 cells, with rows marked by numbers (1-8) and columns marked by letters (a-h). A cell is identified by a pair of letter and number (e.g. f1, c4).
_______________
8 |_|#|_|#|_|#|_|#|
7 |#|_|#|_|#|_|#|_|
6 |_|#|_|#|_|#|_|#|
5 |#|_|#|_|#|_|#|_|
4 |_|#|_|#|_|#|_|#|
3 |#|_|#|_|#|_|#|_|
2 |_|#|_|#|_|#|_|#|
1 |#|_|#|_|#|_|#|_|
a b c d e f g h
A queen can attack an opponent located in any cells horizontally, vertically and diagonally from queen's position.
Given the positions of the queen and the opponent print the distance (opponent is how many cells away from the Queen) between them if the queen can attack otherwise print
Example
Queen position: b4
Opponent position: e1
In this case Queen can attack the opponent and opponent is
Note: The distance is also called
https://en.wikipedia.org/wiki/Chebyshev_distance
Input
Queen and opponent positions separated by space.
Output
Print distance if queen can attack otherwise print CANNOT ATTACK .
Constraints
Example
Input
c5 c8
Output
3
Game modes
Fastest, Shortest
Test cases
Vertical Test
Input
c5 c8
Output
3
Validator 1 Validator
Input
a2 a8
Output
6
Out of Sight 1 Test
Input
a5 d7
Output
CANNOT ATTACK
Validator 2 Validator
Input
b4 d7
Output
CANNOT ATTACK
Horizontal Test
Input
b4 g4
Output
5
Validator 3 Validator
Input
d5 h5
Output
4
Out of Sight 2 Test
Input
g8 a3
Output
CANNOT ATTACK
Validator 4 Validator
Input
h7 b3
Output
CANNOT ATTACK
South-East Test
Input
b4 e1
Output
3
Validator 5 Validator
Input
f2 c5
Output
3
North-West Test
Input
g3 d6
Output
3
Validator 6 Validator
Input
b8 h2
Output
6
Solution language
Solution
Stub generator input