Question: Im lost any help would be nice! (Python) 3.1 arr_of_strs_to_2d_array(strs) Implement a function that takes one parameter, which will be an array of strings. It
Im lost any help would be nice! (Python)




3.1 arr_of_strs_to_2d_array(strs) Implement a function that takes one parameter, which will be an array of strings. It converts the data into a 2d array of single characters. But it's not as simple as just calling list() to convert each string in turn - we want to be able to access the elements of the array like this: grid = ... some_value = grid[x] [y] In order for a 2d array to work this way, we have to use the first index to represent the I value, and the second to represent the y. This means that we must have organize our data into an array of columns. To understand this, let's use a small example of a 4x4 grid. (This problem will actually use 9x9 grids, but those are really annoying to draw! Here's the grid, as you might print it out to the user: abcd X..y 1234 Here's what the input would look like, as an array of strings: strs - [ "abcd", 11 "x..y", "1234" ] While this is very handy for printing, it's not very handy for code - because when you access strs [0] you are accessing the first row, not the first column. For the 2d array that you return, You will need to organize it as follows: grid [['a', '.', 'X', '1'], ['b', '.', '2'] ['c', .', '3'] ['d', 'y', '4']] 2 The cool thing about this form is that grid[0] gives you the first column, and grid[0] [3] is the bottom-left corner. 4 print_grid(grid) This function has one parmater, which is a 2d array of integers. It will always be exactly 9x9 in size, it will be organized as an array of columns," as we discussed in the previous function - meaning that you can index into the array with the syntax grid [x][y]. Each of the values stored in the array will be integers, in the range 0 through 9 (inclusive). When you print out the values, you should out a period every place the array has a zero; otherwise, print out the integer you've been given. You will print out the 9x9 values in the standard Sudoku shape (see above). So, you will need to add spaces in two places on each line, to give empty columns, and blank lines to give empty rows
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
