Public
Edited
Dec 16, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
day6a = [
{ time: 38, distance: 234 },
{ time: 67, distance: 1027 },
{ time: 76, distance: 1157 },
{ time: 73, distance: 1236 }
]
.map((race) =>
d3
.range(race.time)
.slice(1)
.map((speed) => {
let timeRemaining = race.time - speed;
return timeRemaining * speed;
})
.filter((distance) => distance > race.distance)
)
.map((d) => d.length)
.reduce((a, v) => a * v, 1)
Insert cell
day6b = [{ time: 38677673, distance: 234102711571236 }]
.map((race) =>
d3
.range(race.time)
.slice(1)
.map((speed) => {
let timeRemaining = race.time - speed;
return timeRemaining * speed;
})
.filter((distance) => distance > race.distance)
)
.map((d) => d.length)
//.reduce((a, v) => a * v, 1)
Insert cell
Insert cell
Insert cell
cardValues = ({
A: "E",
K: "D",
Q: "C",
J: "B",
T: "A",
"9": 9,
"8": 8,
"7": 7,
"6": 6,
"5": 5,
"4": 4,
"3": 3,
"2": 2
})
Insert cell
Object.entries(cardValues).map((d) => d[0] + " " + String(d[1]).charCodeAt(0))
Insert cell
day7
.split("\n")
.map((d) => d.split(" "))
.map((d) => {
let hand = d[0];
let bid = d[1];

hand = hand
.split("")
.map((c) => cardValues[c])
.join("");

let dupes = hand
.split("")
.sort()
.join("")
.match(/(.)\1+/g);

dupes = dupes ? dupes : [];

return dupes;
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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