Public
Edited
Aug 27, 2023
1 fork
1 star
Insert cell
Insert cell
Insert cell
function part1(input) {
const binary = input.toString(2);
return parseInt(binary.slice(1) + binary[0], 2);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function winningElfAcross(n) {
const p = Math.pow(3, Math.floor(Math.log(n) / Math.log(3)));
return n === p ? n : n - p + Math.max(0, n - 2 * p);
}
Insert cell
function part2(input) {
return winningElfAcross(input);
}
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