# KQM15A editorial

Author: Chandan Boruah
Tester: Jaideep Pyne
Editorialist: Chandan Boruah

#DIFFICULTY:
Easy

#PREREQUISITES:
Coordinate Geometry.

#PROBLEM:
Given a 2D array and source and destination, find number of steps needed to reach from source to destination if diagonal movements not allowed.

#QUICK EXPLANATION:
Find the manhattan distance between the two points.

#EXPLANATION:
Given two points in a 2D grid(array), find the distance between the two points. The distance will be minimum if we travel from one point to the other such that there is minimum turns in the path. Thus we find the difference between the x coordinates and y coordinates of the two points.

#AUTHOR’S SOLUTIONS:
using System;
using System.Collections.Generic;
class some
{
public static void Main()
{
int x=int.Parse(ss[0]);
int y=int.Parse(ss[1]);
int x1=0;
int y1=0;
int x2=0;
int y2=0;
for(int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
int now=int.Parse(ss[j]);
if(now==1)
{
x2=i;y2=j;
}
else if(now==2)
{
x1=i;y1=j;
}
}
}
Console.WriteLine(Math.Abs(x2-x1)+Math.Abs(y2-y1));
}
}

#RELATED PROBLEMS: