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, 21.06.2019 17:30
How are natural numbers, whole numbers, integers, and rational numbers related
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
question
Computers and Technology, 23.06.2019 16:30
20 points archie wants to use a reflector as he photographs a newlywed couple. what would he consider in his choice? a. shadow and sunny b. homemade and professional c. lamps and boards d. incident and reflected e. neutral density and enhancement
Answers: 3
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
question
Chemistry, 21.11.2020 06:20
question
Computers and Technology, 21.11.2020 06:20
question
Mathematics, 21.11.2020 06:20
question
Computers and Technology, 21.11.2020 06:20
question
History, 21.11.2020 06:20
question
Geography, 21.11.2020 06:20
question
Health, 21.11.2020 06:20
Questions on the website: 13722367