Published
Edited
Dec 5, 2020
Insert cell
md`# Advent of Code: Day 5`
Insert cell
parsed = data.trim().split("\n").map(lines => [
parseBinary(lines.substring(0, 7), 'B'),
parseBinary(lines.substring(7, 10), 'R')
])
Insert cell
parseBinary = (str, oneChar) => parseInt(str.split("").map(c => c == oneChar ? 1 : 0).join(""), 2)
Insert cell
parsed.map(([row, col]) => row * 8 + col).sort((a, b) => b - a)
Insert cell
{
let counts = {};
parsed.forEach(([row, col]) => counts[row] = counts[row] ? counts[row] + 1 : 1)
return counts
}
Insert cell
parsed.filter(([row, col]) => row == 81)
Insert cell
Insert cell
import { Table } from '@observablehq/table'
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