Platform
Resources
Pricing
Sign in
Get started
Jo Wood
Professor of Visual Analytics interested in design, geovisualization, visual storytelling and computational thinking.
Workspace
Fork
Public
Ξ🎄Advent of Code 2020
By
Jo Wood
Edited
Nov 11, 2022
1 star
Insert cell
Insert cell
function
part1
(
xs
)
{
for
(
let
i
=
0
;
i
<
xs
.
length
;
i
++
)
{
for
(
let
j
=
i
+
1
;
j
<
xs
.
length
;
j
++
)
{
if
(
xs
[
i
]
+
xs
[
j
]
==
2020
)
{
return
xs
[
i
]
*
xs
[
j
]
;
}
}
}
return
"No pair found"
;
}
Insert cell
Insert cell
Insert cell
Insert cell
function
removeLarge
(
xs
,
n
=
1
)
{
const
minSum
=
AOC
.
sum
(
AOC
.
sort
(
xs
)
.
slice
(
0
,
n
)
)
;
return
xs
.
filter
(
x
=>
x
+
minSum
<=
2020
)
;
}
Insert cell
Insert cell
Insert cell
Insert cell
function
part2
(
xs
)
{
for
(
let
i
=
0
;
i
<
xs
.
length
;
i
++
)
{
for
(
let
j
=
i
+
1
;
j
<
xs
.
length
;
j
++
)
{
for
(
let
k
=
j
+
1
;
k
<
xs
.
length
;
k
++
)
{
if
(
xs
[
i
]
+
xs
[
j
]
+
xs
[
k
]
==
2020
)
{
return
xs
[
i
]
*
xs
[
j
]
*
xs
[
k
]
;
}
}
}
}
return
"No pair found"
;
}
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
part1
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
removeLarge
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
part2
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
$
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
test1
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
puzzleInput
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML
JavaScript
Markdown
HTML