Public
Edited
Oct 9, 2023
Insert cell
Insert cell
adventOfCodeHeader(2022, 14)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
drawPath = R.curry((map, fill, path) => )
Insert cell
buildMap = bounds => {
const size = bounds.map(([a, b]) => b - a + 1)

return {
bounds: bounds,
size,
data: new Array(size[0] * size[1]).fill(null)
}
}
Insert cell
parsePath = R.pipe(
R.split(' -> '),
R.map(R.pipe(R.split(','), R.map(parseInt)))
)
Insert cell
parsePaths = R.pipe(
R.split('\n'),
R.map(parsePath)
)
Insert cell
getBounds = R.pipe(
x => x.flat(),
R.transpose,
R.map(x => [Math.min(...x), Math.max(...x)]),
R.transpose
)
Insert cell
isOutOfBounds = R.curry((bounds, v) => v.some((c, i) => c < bounds[0][i] || c > bounds[1][i]))
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