subject

How can I reduce the number of loops, possibly into one loop on my solution below? The logic is right and it passes all my test cases but it looks a bit verbose. const hourglassSum = (arr) => { let count = 1; const hourglass = []; const flatglass = []; let idx = 0; do { const idx2 = idx + 1; const idx3 = idx + 2; hourglass. push([ [arr[0][idx], arr[0][idx2], arr[0][idx3]], [0, arr[1][idx2], 0], [arr[2][idx], arr[2][idx2], arr[2][idx3]], ]); idx += 1; count += 1; } while (count 4 && count 8 && count 12 && count { const flattened = [].concat(...innerglass); const arrSum = flattened. reduce((a, b) => a + b, 0); flatglass. push(arrSum); }); return Math. max(...flatglass); };

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
How can a user open a blank presentation? 1.on the file menu, click new, and then click recent templates 2.on the file menu, click new, and then click blank presentation 3. on the view menu, click templates, and then click recent templates 4. on the view menu, click samples, and then click blank presentation
Answers: 1
question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
Your computer running windows 10 is doing some very strange things with the operating system. you are fairly certain it is not a hardware issue. you need to try to get further insight into what is going on within the operating system. which tool would be best suited for this?
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
You know the right answer?
How can I reduce the number of loops, possibly into one loop on my solution below? The logic is righ...
Questions
Questions on the website: 13722361