Skip to content

Feature/sonarcloud bugfixes #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/projecteuler/lib/BNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class BNodeBuilder extends BNode {
if (dataTree[i]?.[j]) {
const resultNode = new BNode(dataTree[i][j]);

if (dataTree[i + 1] && dataTree[i + 1][j] && dataTree[i + 1][j + 1]) {
if (dataTree?.[i + 1]?.[j] && dataTree?.[i + 1]?.[j + 1]) {
// Next left coordinates: [i + 1][j]
resultNode.setLeft(BNodeBuilder.buildBNodeTree(dataTree, i + 1, j));

Expand All @@ -34,7 +34,7 @@ export default class BNodeBuilder extends BNode {
if (dataTree[i]?.[j]) {
const resultNode = new BNode(dataTree[i][j] + rootValue);

if (dataTree[i + 1] && dataTree[i + 1][j] && dataTree[i + 1][j + 1]) {
if (dataTree?.[i + 1]?.[j] && dataTree?.[i + 1]?.[j + 1]) {
// Next left coordinates: [i + 1][j]
resultNode.setLeft(
BNodeBuilder.buildBNodeTreeWeigth(
Expand Down
3 changes: 2 additions & 1 deletion src/projecteuler/problem0018.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export function problem0018(_triangle) {
console.debug('_triangle', JSON.stringify(weightsTree, null, 4));
console.debug('leafs count', leafs.length, 'leafs', leafs);

const max = leafs.reduce((a, b) => (a > b ? a : b));
const __START_FROM__ = 0;
const max = leafs.reduce((a, b) => (a > b ? a : b), __START_FROM__);

return max;
}
Expand Down
Loading