Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in Julia Part 2 - Simulate the walk Next we will write the function to simulate the walk and produce the sequence. This function

Code in Juliaimage text in transcribed

Part 2 - Simulate the walk Next we will write the function to simulate the walk and produce the sequence. This function will take an initialized board as input, and produce a list of numbers as well as the corresponding - and y-coordinates. For example, the following input: board - initialize_board (2) display(board) seq, xs, ys - simulate_walk (board); println("Sequence = ", seg) println("x-coordinates - ", XS) println("y-coordinates = ", ys) 11 should produce the following correct output: 5x5 Array{Int64,2}: 17 16 15 14 13 18 5 4 3 12 19 6 1 2 11 20 7 8 9 10 21 22 23 24 25 Sequence = [1, 10, 3, 6, 9, 4, 7, 2, 5, 8, 11, 14] x-coordinates = [0, 2, 1, -1, 1, 0, -1, 1, -1, 0, 2, 1] y-coordinates = [0, 1, -1, 0, 1, -1, 1, 0, -1, 1, 0, -2] Again test your code, first using small values of n as shown above, which makes it easier to look at the results and find errors. Hints: It is convenient to create another 2d-array of booleans, indicating if a square has been visited or not. Make sure you never allow the knight to jump outside the board. That is, the only valid positions are n steps from the center square in either direction Part 2 - Simulate the walk Next we will write the function to simulate the walk and produce the sequence. This function will take an initialized board as input, and produce a list of numbers as well as the corresponding - and y-coordinates. For example, the following input: board - initialize_board (2) display(board) seq, xs, ys - simulate_walk (board); println("Sequence = ", seg) println("x-coordinates - ", XS) println("y-coordinates = ", ys) 11 should produce the following correct output: 5x5 Array{Int64,2}: 17 16 15 14 13 18 5 4 3 12 19 6 1 2 11 20 7 8 9 10 21 22 23 24 25 Sequence = [1, 10, 3, 6, 9, 4, 7, 2, 5, 8, 11, 14] x-coordinates = [0, 2, 1, -1, 1, 0, -1, 1, -1, 0, 2, 1] y-coordinates = [0, 1, -1, 0, 1, -1, 1, 0, -1, 1, 0, -2] Again test your code, first using small values of n as shown above, which makes it easier to look at the results and find errors. Hints: It is convenient to create another 2d-array of booleans, indicating if a square has been visited or not. Make sure you never allow the knight to jump outside the board. That is, the only valid positions are n steps from the center square in either direction

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

Step: 3

blur-text-image

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago