Published
Edited
Dec 8, 2020
Insert cell
md`# Advent of code 2020 - day 1`
Insert cell
answer2 = {
let solution = [];
data.forEach(e => {
data.forEach(e2 => {
data.forEach(e3 => {
if (parseInt(e) + parseInt(e2) + parseInt(e3) === 2020) {
solution = [e, e2, e3];
}
});
});
});
return solution.reduce((a, b) => a * b);
}
Insert cell
answer1 = {
let solution = [];
data.forEach(e => {
data.forEach(e2 => {
if (parseInt(e) + parseInt(e2) === 2020) {
solution = [e, e2];
}
});
});
return solution.reduce((a, b) => a * b);
}
Insert cell
data = input
.split('\n')
.map(el => +el)
.sort((a, b) => b - a)
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