Platform
Resources
Pricing
Sign in
Get started
Casey Labrack
Workspace
Fork
Published
advent of code 2020
By
Casey Labrack
Edited
Dec 1, 2020
Insert cell
Insert cell
solutionizer
(
sumScanPair
)
// part 1
Insert cell
solutionizer
(
sumScanTrip
)
// part 2
Insert cell
solutionizer
=
thingDoer
(
input
)
Insert cell
thingDoer
=
data
=>
func
=>
func
(
data
.
split
(
"\n"
)
.
map
(
Number
)
,
2020
)
.
reduce
(
(
acc
,
inc
)
=>
acc
*
inc
,
1
)
// product of array
Insert cell
sumScanPair
=
function
(
arr
,
sum
)
{
for
(
let
i
=
0
;
i
<
arr
.
length
-
1
;
i
++
)
{
for
(
let
j
=
i
+
1
;
j
<
arr
.
length
;
j
++
)
{
if
(
arr
[
i
]
+
arr
[
j
]
==
sum
)
return
[
arr
[
i
]
,
arr
[
j
]
]
}
}
}
Insert cell
sumScanTrip
=
function
(
arr
,
sum
)
{
for
(
let
i
=
0
;
i
<
arr
.
length
-
2
;
i
++
)
{
for
(
let
j
=
i
+
1
;
j
<
arr
.
length
-
1
;
j
++
)
{
for
(
let
k
=
j
;
k
<
arr
.
length
;
k
++
)
{
if
(
arr
[
i
]
+
arr
[
j
]
+
arr
[
k
]
==
sum
)
return
[
arr
[
i
]
,
arr
[
j
]
,
arr
[
k
]
]
}
}
}
}
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
solutionizer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
thingDoer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sumScanPair
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sumScanTrip
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
input
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML