Public
Edited
Dec 1, 2023
Insert cell
Insert cell
Insert cell
function move(floor, c) {
return c === "(" ? floor + 1 : floor - 1;
}
Insert cell
Insert cell
function part1(input) {
return [...input].reduce(move, 0);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function part2(input) {
return AOC.scanl([...input], move, 1).indexOf(-1);
}
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