Public
Edited
Dec 8, 2022
1 fork
Importers
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = parse(inputs.real)
Insert cell
tidyData = data.flatMap((foods, elf) =>
foods.map((calories, snack) => ({ elf, calories, snack }))
)
Insert cell
Insert cell
parse = aoc.paragraphLines(Number)
Insert cell
part1 = genericPart(1)
Insert cell
part2 = genericPart(3)
Insert cell
function genericPart(n) {
return (input) => {
let sums = input.map((elf) => d3.sum(elf));
sums = d3.sort(sums, (d) => -d);
return d3.sum(sums.slice(0, n));
};
}
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