mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-20 10:37:07 +08:00
Removed mistakenly added semicolon
This commit is contained in:
@ -1,26 +1,26 @@
|
||||
// Problem: https://projecteuler.net/problem=8
|
||||
|
||||
const largestAdjacentNumber = (grid, consecutive) => {
|
||||
grid = grid.split('\n').join('');
|
||||
const splitedGrid = grid.split("\n");
|
||||
let largestProd = 0;
|
||||
grid = grid.split('\n').join('')
|
||||
const splitedGrid = grid.split('\n')
|
||||
let largestProd = 0
|
||||
|
||||
for (let row in splitedGrid) {
|
||||
const currentRow = splitedGrid[row].split('').map(x => Number(x));
|
||||
for (const row in splitedGrid) {
|
||||
const currentRow = splitedGrid[row].split('').map(x => Number(x))
|
||||
|
||||
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)) {
|
||||
const product = combine.reduce(function (a, b) {
|
||||
return a * b
|
||||
});
|
||||
})
|
||||
|
||||
if (largestProd < product) largestProd = product;
|
||||
if (largestProd < product) largestProd = product
|
||||
}
|
||||
}
|
||||
}
|
||||
return largestProd;
|
||||
return largestProd
|
||||
}
|
||||
|
||||
export { largestAdjacentNumber };
|
||||
export { largestAdjacentNumber }
|
||||
|
Reference in New Issue
Block a user