Published
Edited
Dec 12, 2020
1 fork
1 star
Insert cell
Insert cell
part1 = passes.map(decode).map(seatId).sort((a, b) => b - a)[0]
Insert cell
part2 = vl.markRect({ tooltip: true, stroke: 'white' })
.data(passes.map(decode).map(([row, column]) => ({row, column, seatId: seatId([row, column])})))
.encode(
vl.x().fieldO('row').axis({ labelOverlap: true }),
vl.y().fieldO('column'),
vl.detail().fieldN('seatId'),
)
.width(width)
.autosize({ type: 'fit-x', contains: 'padding' })
.render()
Insert cell
seatId = ([row, column]) => row * 8 + column
Insert cell
decode = (str) => [str.substring(0, 7), str.substring(7)].map(partition)
Insert cell
partition = (str) => parseInt(str.split('').map(l => l === 'B' || l === 'R' ? 1 : 0).join(''), 2)
Insert cell
passes = input.trim().split('\n')
Insert cell
Insert cell
import { vl } from '@vega/vega-lite-api'
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