Public
Edited
Dec 1, 2023
Insert cell
Insert cell
Insert cell
function dimensions(input) {
return input.split("\n").map((line) => AOC.sort(line.split("x").map(Number)));
}
Insert cell
Insert cell
function paperArea([l1, l2, l3]) {
return 2 * (1.5 * l1 * l2 + l2 * l3 + l3 * l1);
}
Insert cell
function part1(input) {
return AOC.sum(dimensions(input).map(paperArea));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function ribbonLength([l1, l2, l3]) {
return 2 * (l1 + l2) + l1 * l2 * l3;
}
Insert cell
function part2(input) {
return AOC.sum(dimensions(input).map(ribbonLength));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more