Back
Close

The lost child.Episode-1

Statement

 Goal

The 12 year old child has lost his mother and now he wants to meet his mother.Somehow child navigated to his mother but he wanna know exact shortest distance and in order to help him you have to tell him exact shortest distance .each block =10km
Input
map 10*10 first ten lines input string row only consist of '.' means road where child can move,'#'-means wall where he can't move,'M'-position of mother,'C'-position of child.
NOTE-child can't move diagonally.
Output
one line with the shortest ditance which child have to travel in order to reach his mother
NOTE-Get ready for Episode 2.
Constraints
length of each row will be 10 and consist of only:-
'.'-Road where child can move(empty space)
'#'-wall child can't move
'M'-position of his mother
'C'-position of child
There will always be a solution
Example
Input
..........
M....C....
..........
..........
..........
..........
..........
..........
..........
..........
Output
50km

Tags
Pathfinding2D arrayBFS

Difficulty
Medium

Test cases
Lost in playground Test
Input
.......... M....C.... .......... .......... .......... .......... .......... .......... .......... ..........
Output
50km

Validator 1 Validator
Input
.......... M......... .C........ .......... .......... .......... .......... .......... .......... ..........
Output
20km

Lost in paris Test
Input
.......... M#........ #C##...... .......... .......... .......... .......... .......... .......... ..........
Output
120km

Validator 2 Validator
Input
.......... .#M....... #C##...... .......... .......... .......... .......... .......... .......... ..........
Output
80km

Lost in jungle Test
Input
########## #...#C...# #...##...# ###.#..### #.##M#...# #.....#..# #.....#..# #.....#..# #........# ##########
Output
160km

Validator 3 Validator
Input
########## #...#C...# #...##...# ###....### #M##.#...# #.....#..# #.....#..# #.....#..# #........# ##########
Output
110km

Lost in Maze Runner Test
Input
########## #..M#C...# #...##...# ###..#.### #.##.#...# #.....#..# #.....#..# #.....#..# #........# ##########
Output
200km

Validator 4 Validator
Input
########## #..M#C...# #...##...# #.#..#.### #.####...# #.....#..# #.....#..# #.....#..# #........# ##########
Output
240km

Lost in Space Test
Input
########## #...#....# #.C.#.#..# ###.#..### #M#......# #.###.#..# #.#....#.# #..#.##..# #........# ##########
Output
170km

Validator 5 Validator
Input
########## #...#....# #.C...#..# ###.#..### #M##.#...# #...#.#..# #.....#..# #.....#..# #........# ##########
Output
210km

Solution language

Solution

Stub generator input