Public
Edited
Dec 15, 2022
Insert cell
Insert cell
moves = parseMovements(input)
Insert cell
stacks = parseStacks(input)
Insert cell
finalStack9000 = crateMover9000(stacks, moves)
Insert cell
finalConfig9000 = finalConfig(finalStack9000)
Insert cell
finalStack9001 = crateMover9001(stacks, moves)
Insert cell
finalCrates9001 = finalConfig(finalStack9001)
Insert cell
Insert cell
finalConfig = (stacks) => stacks.map(_.last).join("")
Insert cell
Insert cell
Insert cell
cloneMatrix = (matrix) => [...matrix].map((row) => [...row])
Insert cell
input = puzzleInput
Insert cell
splitAt(["M", "C", "D"], 2)
Insert cell
splitAt = (list, k) => [[...list.slice(0, k)], [...list.slice(k, list.length)]]
Insert cell
Insert cell
function parseMovements(inputText) {
const [_stacks, textMoves] = inputText.split(`${NEWLINE}${NEWLINE}`);
return textMoves.trim().split(NEWLINE).map(parseMoveLine);
}
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