Back
Close

Manhattan Maths

Statement

 Goal

Output the Manhattan distance between the "$" characters on an N x N grid. Manhattan distance is the horizontal distance + vertical distance.
Input
Line1: An integer N for the side length of the grid.
Next N lines: The N x N grid
Output
Line 1: TheManhattan distance between the "$" characters.
Constraints
4 ≤ N ≤ 20
Example
Input
4
****
*$$*
*  *
****
Output
1

Game modes
Fastest, Reverse

Test cases
Test 1 Test
Input
4 **** *$$* * * ****
Output
1

Validator 1 Validator
Input
4 **** *$ * * $* ****
Output
2

Test 2 Test
Input
5 ***** * $* * * * $ * *****
Output
3

Validator 2 Validator
Input
5 ***** * $* * * *$ * *****
Output
4

Test 3 Test
Input
6 ****** * $* * * * * * $ * ******
Output
5

Validator 3 Validator
Input
7 ******* * $* * $ * * * * * * * *******
Output
2

Test 4 Test
Input
10 ********** * $ * * * * * * * * * * * * $ * * * **********
Output
11

Validator 4 Validator
Input
11 *********** * $ * * * * * * * * * * * * * * * * $ * ***********
Output
9

Solution language

Solution

Stub generator input