Public
Edited
Nov 19, 2022
11 forks
1 star
Insert cell
Insert cell
function fuel(mass) {
return Math.floor(mass / 3) - 2;
}
Insert cell
function part1(input) {
return AOC.sum(input.map(fuel));
}
Insert cell
Insert cell
Insert cell
Insert cell
function fuel2(total, mass) {
const f = fuel(mass);
return f <= 0 ? total : fuel2(total + f, f);
}
Insert cell
function part2(input) {
return AOC.sum(input.map((m) => fuel2(0, m)));
}
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