Removed mistakenly added semicolon

This commit is contained in:
Omkarnath Parida
2021-10-02 23:55:41 +05:30
parent 8b1d10df78
commit b38a94dda5
2 changed files with 15 additions and 15 deletions

View File

@ -1,26 +1,26 @@
// Problem: https://projecteuler.net/problem=8 // Problem: https://projecteuler.net/problem=8
const largestAdjacentNumber = (grid, consecutive) => { const largestAdjacentNumber = (grid, consecutive) => {
grid = grid.split('\n').join(''); grid = grid.split('\n').join('')
const splitedGrid = grid.split("\n"); const splitedGrid = grid.split('\n')
let largestProd = 0; let largestProd = 0
for (let row in splitedGrid) { for (const row in splitedGrid) {
const currentRow = splitedGrid[row].split('').map(x => Number(x)); const currentRow = splitedGrid[row].split('').map(x => Number(x))
for (let i = 0; i < currentRow.length - consecutive; i++) { for (let i = 0; i < currentRow.length - consecutive; i++) {
const combine = currentRow.slice(i, i + consecutive); const combine = currentRow.slice(i, i + consecutive)
if (!combine.includes(0)) { if (!combine.includes(0)) {
const product = combine.reduce(function (a, b) { const product = combine.reduce(function (a, b) {
return a * b return a * b
}); })
if (largestProd < product) largestProd = product; if (largestProd < product) largestProd = product
} }
} }
} }
return largestProd; return largestProd
} }
export { largestAdjacentNumber }; export { largestAdjacentNumber }

View File

@ -1,4 +1,4 @@
import { largestAdjacentNumber } from '../Problem8'; import { largestAdjacentNumber } from '../Problem8'
const grid1 = `73167176531330624919225119674426574742355349194934 const grid1 = `73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843 96983520312774506326239578318016984801869478851843
@ -19,7 +19,7 @@ const grid1 = `73167176531330624919225119674426574742355349194934
84327878357761783787589375857378271083787811983779 84327878357761783787589375857378271083787811983779
84580156166097919133875499200524063689912560717606 84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725 05886116467109405077541002256983155200055935729725
82347875831098357801578571807585817518287829189189`; 82347875831098357801578571807585817518287829189189`
const grid2 = `73167176531330624919225119674426574742355349194934 const grid2 = `73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843 96983520312774506326239578318016984801869478851843
@ -40,7 +40,7 @@ const grid2 = `73167176531330624919225119674426574742355349194934
07198403850962455444362981230987879927244284909188 07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606 84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725 05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450`; 71636269561882670428252483600823257530420752963450`
const grid3 = `89125732138957892357892768971807934878999818278898 const grid3 = `89125732138957892357892768971807934878999818278898
48327483578957875827583295789187588875238579887789 48327483578957875827583295789187588875238579887789
@ -61,7 +61,7 @@ const grid3 = `89125732138957892357892768971807934878999818278898
10783974839479879857895789758975981735870175835789 10783974839479879857895789758975981735870175835789
01494787857897583758975849758475107589754897589789 01494787857897583758975849758475107589754897589789
09939858758919788017587897587387585775289757982898 09939858758919788017587897587387585775289757982898
74718478978758758975897589789789798789178957789789`; 74718478978758758975897589789789798789178957789789`
const grid4 = `99999999999999999999999999999999999999999999999999 const grid4 = `99999999999999999999999999999999999999999999999999
99999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999
@ -82,7 +82,7 @@ const grid4 = `99999999999999999999999999999999999999999999999999
99999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999
99999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999
99999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999
99999999999999999999999999999999999999999999999999`; 99999999999999999999999999999999999999999999999999`
describe('checkLargestAdjacentNumberProduct', () => { describe('checkLargestAdjacentNumberProduct', () => {
it('Random Example', () => { it('Random Example', () => {