Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Code can be in Julia or Matlab.. no preference. Part 1 - Initialize the board We will store the chess board in a 2d-array of

Code can be in Julia or Matlab.. no preference.

image text in transcribed

Part 1 - Initialize the board We will store the chess board in a 2d-array of integers. The size of the board is (2n + 1)-by- (2n + 1), for a given integer n. This means the board extends from the center square by n steps in all directions. The first step is to initialize the board by filling it with the integers described in the video. Finish the implementation of the function definition in the cell below such that it returns this "spiral pattern" for any given input parameter n. An example is given below: for the following input board = initialize_board (3) the correct output is 7x7 Array{Int64,2}: 37 36 35 34 33 32 38 17 16 15 14 13 39 18 5 4 3 12 29 40 19 6 1 2 11 28 41 20 7 8 9 10 27 42 21 22 23 24 25 26 43 44 45 46 47 48 49 Test your function for various values of n to make sure it is correct before you continue. Hints: Note that since Julia uses 1-based indexing, the center square of the array board is given by element board[n+1, n+1] . After the center 1 has been placed, there are exactly n "circles" of numbers of increasing radius. This is naturally implemented using a for-loop. In each "circle", there are 4 segments going up, left, down, and right. These are also naturally implemented using a sequence of 4 for-loops

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago