Question
JAVASCRIPT Help I have a 2d array that has 9 arrays with 9 elements in each array. [[0,0,0,0,8,0,4,6,1],[0,9,8,0,0,3,0,0,0],[0,0,0,0,0,0,0,0,0],[0,7,0,0,5,4,8,1,0], [2,0,0,0,0,0,0,4,0],[1,0,5,0,0,0,0,0,0],[0,5,0,0,0,7,3,0,2],[0,0,2,0,0,0,0,7,0],[0,0,0,0,6,0,0,0,0]]; I need to get the first
JAVASCRIPT Help
I have a 2d array that has 9 arrays with 9 elements in each array.
[[0,0,0,0,8,0,4,6,1],[0,9,8,0,0,3,0,0,0],[0,0,0,0,0,0,0,0,0],[0,7,0,0,5,4,8,1,0], [2,0,0,0,0,0,0,4,0],[1,0,5,0,0,0,0,0,0],[0,5,0,0,0,7,3,0,2],[0,0,2,0,0,0,0,7,0],[0,0,0,0,6,0,0,0,0]];
I need to get the first three elements out of 3 arrays at a time and create another 2d array with that. This would look like [0,0,0,0,9,8,0,0,0], [0,8,0,0,0,3,0,0,0],[4,6,1,0,0,0,0,0,0] for the first 3. If you think of the initial 2d array like a 9x9 matrix, I need to create 9, 3x3 boxes starting in the top left, going to the right, then the middle left, middle right, bottom, left, bottom right.
I need a function that changes that initial array into the new one as described. In JavaScript.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started