22 lines
600 B
JavaScript
22 lines
600 B
JavaScript
const { Glib } = require('../../lib');
|
|
|
|
module.exports = {
|
|
'1': (input) =>
|
|
Glib.fromLines(input)
|
|
.map((i) => {
|
|
const [x, y, z] = i.split('x').glib.toInts().array;
|
|
const sides = [x * y, y * z, z * x];
|
|
return sides.glib.sum() * 2n + sides.glib.min();
|
|
})
|
|
.sum(),
|
|
2: (input) =>
|
|
Glib.fromLines(input)
|
|
.map((i) => {
|
|
const vertices = i.split('x').glib.toInts().array;
|
|
const [x, y, z] = vertices;
|
|
const sides = [x + y, y + z, z + x];
|
|
return sides.glib.min() * 2n + vertices.glib.product();
|
|
})
|
|
.sum(),
|
|
};
|