Published unlisted
Edited
Dec 4, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
checksum = {
let twos = 0;
let threes = 0;
for(let i = 0; i < repeats.length; i++) {
if (repeats[i].exactly.twice) twos++;
if (repeats[i].exactly.thrice) threes++;
}
return {twos, threes, checksum: twos * threes};
}
Insert cell
boxes = {
let input = day_two_input.slice(0);
let diffs = [];
for(let i = 0; i < 26; i++) {
const sortByCharAt_i = (a, b) => a[i] - b[i];
input.sort(sortByCharAt_i);
for(let j = 0; j < input.length-1; j++) {
let boxA = input[j];
let boxB = input[j+1];
let diff = 0;
for(let k = 0 ; k < boxA.length; k++) {
if (boxA[k] !== boxB[k]) diff++;
}
diffs.push(diff);
if (diff === 1) {
return {boxA, boxB};
}
}
}
diffs.sort();
return diffs;
}
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