Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this: 5. The Swiss mathematician Leonhard Euler (1707-1783) proposed a problem regarding the movement of the knight chess piece on a

I need help with this:

image text in transcribed

image text in transcribed

image text in transcribed

5. The Swiss mathematician Leonhard Euler (1707-1783) proposed a problem regarding the movement of the knight chess piece on a chess board. The challenge that Euler proposed was to move the knight around an empty chessboard, and to touch each of the 64 squares once and only once. First, to understand what you have to do, move a knight from any position on the board using its standard L-shaped moves (two over in one direction, then one in a perpendicular direction). Number any position as 1 and then visit as many squares as possible, numbering each move as you go: 1 2 3 4 5 6 7 8 Assignment: Your task in this lab is to write a program that will move a knight around an empty chess board, leaving behind a trail of increasing integers, ranging from 1 to, hopefully, 64. Here are the specifications for your assignment: 1. The knight will start in row 1, column l. 2. The program will mark squares as they are visited, ranging from 1-64. 3. The program will continue until a complete tour is accomplished (all 64 squares) or the program gets stuck with nowhere to go. 4. The program will print the results, looking something like this: 1 2 3 4 5 6 7 8 1 1 0 23 12 20 0 21 06 09 0 4 0 0 25 18 31 0 33 6 0 22 15 10 35 42 29 0 8 3 34 17 30 14 11 46 37 44 39 26 41 36 47 16 0 32 0 8 47 squares were visited Now, once you get started on this assignment you will quickly discover that this is actually a pretty tough problem. There are two approaches. Adhering to the basic moving rules (two squares up/down, one over left/right; one square up/down, two over left/right) you can... move your knight randomly. I discourage you from pursuing this approach because chances are slim to none that you will actually hit all 64 squares. b) develop an algorithm that uses logic. If we analyze each square, we notice that some are more accessible than others. The squares on the edges are more difficult to visit than the squares not on an edge. By this logic, you can see that the corners are the most difficult. or inaccessible, squares of all. Here is an analysis of the accessibility of each square. 1 2 3 4 5 6 7 8 2 3 4 4 4 4 3 2 2 3 4 3 4 6 8 8 8 8 64 A square with an accessibility of 8 means that it can be approached from 8 different other squares. A corner square is rated at 2, while the edges are rated at 3 or 4. It makes sense to try and visit squares with lower accessibility values first, leaving the more accessible middle squares for later in the algorithm

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago

Question

Stages of a Relationship?

Answered: 1 week ago