Question: 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 JuliaCode in Julia Part 2 - Simulate the walk Next we will

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!