0

can somebody help me with this program??
i have to program a matrix with n column and n row and it should be able to find a path moving like a knight in chess game(L) that touch every point of the matrix once. the program consist in enter the location where i want to start (n,n) n=1,2,3,4,5 and the computer will calculate the path...
ex: starting from (1,1) we have:
1 6 15 10 21
14 9 20 5 16
19 2 7 22 11
8 13 24 17 4
25 18 3 12 23
you can see that the sequence of the numbers is in L. i need at least a start head

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by boblied
0

can somebody help me with this program??
[...] find a path moving like a knight in chess game(L) that touch every point of the matrix once. ...

Head start: from the current position, make a list of all the possible next moves that go to a position that hasn't been visited yet. Try the first one. If that doesn't complete the matrix, make a list of all the new possible moves. Try the first one. Repeat. If you ever find yourself with no more moves and the matrix still not covered, back out the most recent move and try the next one on the list. If you run out of moves on the list, back out to the previous list of moves. Stacks, lists, and recursion are likely to be involved.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.