Public
Edited
May 30, 2023
Insert cell
Insert cell
str = "de156a2fc8"
Insert cell
Insert cell
str.length
Insert cell
Insert cell
"fd94de585b2c3ba5".length
Insert cell
Insert cell
Math.random().toString(16).slice(2, 2 + str.length)
Insert cell
Insert cell
chars = [...str]
Insert cell
Plot.auto(chars, { x: (d) => d }).plot({ height: 80 })
Insert cell
Insert cell
Plot.auto(chars, { x: (d) => d }).plot({
height: 80,
x: { domain: d3.range(0, 16).map((d) => d.toString(16)) }
})
Insert cell
Insert cell
getRandomHex = () => Math.random().toString(16).slice(2, 2 + str.length)
Insert cell
ex = getRandomHex()
Insert cell
Insert cell
usesDigitMultipleTimes = (str) =>
d3.rollups([...str], (arr) => arr.length, (d) => d)
.filter(([, count]) => count > 1).length > 0
Insert cell
usesDigitMultipleTimes(ex)
Insert cell
Insert cell
d3.range(10).map(getRandomHex).map(n => [n, usesDigitMultipleTimes(n)].join(" ")).join("\n")
Insert cell
Insert cell
getFraction = (n, generator, predicate) => d3.range(n).map(generator).filter(predicate).length / n
Insert cell
frac = getFraction(1000, getRandomHex, usesDigitMultipleTimes)
Insert cell
d3.format(".1%")(frac)
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