All-Star

20513 Points

5712 Posts

### Re: need solution to this problem in c#- help

is this a homework assignment:

#### ashok2009cse

can any one solve and tell me the logic with source code

probably mathematicians who specialize in graph theory could mentor you; you might have to write the code yourself

#### ashok2009cse

There is an infinite integer grid

it's unsolvable if it's infinite.

#### ashok2009cse

From any given cell, all 8 adjacent cells are reachable in 1 unit of time.

no, edge cells can reach fewer houses ... look at a chess board

N.B.:  let's use a chess board, home position, as an example,

rowas are 1 to 8; columns are a to h

let's say that both White bishops (c1 and f1) wish to meet with their count parts (c8 and f8) at d4

if your cells are squares of the same size, like the chessboard, then your problem is simple ...

however, since you do not know where the meeting will take place, in pseudo code, your logic would be something like this ...

(a) create an arrary (Int32, Int32) of n by m where n is the total number of cells (64), m are the number of participants

[0, 0] would be the distance for the c1 bishop to a1 (2);
[0, 1] would be the distance for the f1 bishop to a1 (5);
et cetera

b) you'd also need to store your path ... for c1 to a1, the path is c1==>b1==> a1

(c) NOTE:  a1 is the White Queen Rook's house ... you said someone's house so according to your problem definition, that someone might not be one of the people who wish to meet.

(d) your problem is simpler if the someone's house must be a home of one of the meeting participants ... for this restricted case, the distance for one participant will always be zero.  so you basically would compute the routes from everybody to everybody else ...

note:  in the case of the four bishops, any house will do because of the symmetry of their positions on the chessboard.

g.