KNIGHTS TOUR

I have had to summit the question again
because i cannot edit the question i set earlier cookies problem

but here it is again a bit clearer to understand i hope

Knights tour problem
I need the design for a 2d array for where the user inputs the starting position for the knight
The program then displays all the subsequent moves in rows of eight
the user inputs any postion
say 2b the program then has to display
all the 64 positions the knight will travel
from to complete its tour of the board
the result will be displayed in rows and
columns of eight
{user inputs 1a}
 
output

1a 3b 2d 1f 3g 2e ect

the program does not have to be a 2d array
but as i am just starting to learn what
2d arrays do i thought this would be a better way of doing it
instead of using a load of if and else statements

cheers
gandalph
gandalphAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

scrapdogCommented:
I am assuming you want to find the smallest amount of moves the knight can make to visit every square on the board?

If this is the case, you can use a 2-d array to store booleans indicating whether or not the square has been visited.

For each square, there is a number of legal moves a knight can make.  Using recursion, find out which move will result in the least number of moves in the long run.  When a knight moves to a square that hasn't been visited, mark it as true, and decrement a counter (initialized as 64).  When the counter reaches zero, you have found a path.  Try all possible combinations, and the one that takes the least number of moves would be the best solution.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dbruntonCommented:
You need to have one of your questions deleted.

Contact the help desk and specify the question number that you want deleted.

I hope that you are not asking for the algorithm to solve the problem.  The other question has a comment that gives an idea of the array to hold what you want.  Also especially read scrapdog's comment above.

Have fun.
0
gandalphAuthor Commented:
i have tried the 2d array but i am having loads of probs i need to set up the array so that that it shows on the user screen columns a to h & rows 1 to 8 with the rest showing zero like this
  a b c d e f g h
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0

and so on

i do not know how to set the array up so that it will show this table

also when the user inputs from any starting point say b1 the screen will then display 'x' in the table at b1

i can get a table displayed but it only shows 8 rows and 8 columns of zeros

and when user inputs say b1 the table just shows the value 1 at h8

i need some serious help with this one
any offers

gandalph
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

john_pradeepCommented:
Hi! Gandalph,
i am stuck with the same problem...i was wondering if you could help in anyway.
0
gandalphAuthor Commented:
yeh hi john
sorry a bit late in answering been away
send me your email address
and i will send you some code
0
gandalphAuthor Commented:
yeh hi john
sorry a bit late in answering been away
send me your email address
and i will send you some code
0
gandalphAuthor Commented:
yeh hi john
sorry a bit late in answering been away
send me your email address
and i will send you some code
0
john_pradeepCommented:
Hi ! Gandalph ,

My email id is kolijoe@hotmail.com.
thanks
0
john_pradeepCommented:
Hi!

I was basically looking for a solution in c++.

thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.