-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproblem0018.js
More file actions
36 lines (29 loc) · 882 Bytes
/
problem0018.js
File metadata and controls
36 lines (29 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @link Problem definition [[docs/projecteuler/problem0018.md]]
*/
import { BNodeBuilder } from './lib/BNodeBuilder.js';
import { logger as console } from '../logger.js';
const rootCoordinateI = 0;
const rootCoordinateJ = 0;
function problem0018(_triangle) {
console.debug('_triangle', _triangle);
console.debug(
'_triangle',
JSON.stringify(BNodeBuilder.buildBNodeTree(_triangle, 0, 0), null, 4)
);
const leafs = [];
const weightsTree = BNodeBuilder.buildBNodeTreeWeigth(
_triangle,
rootCoordinateI,
rootCoordinateJ,
0,
leafs
);
console.debug('_triangle', JSON.stringify(weightsTree, null, 4));
console.debug('leafs count', leafs.length, 'leafs', leafs);
const __START_FROM__ = 0;
const max = leafs.reduce((a, b) => Math.max(a, b), __START_FROM__);
return max;
}
export default { problem0018 };
export { problem0018 };