Platform
Resources
Pricing
Sign in
Get started
George Hotelling
Workspace
Fork
Published
Advent of Code 2021
By
George Hotelling
Edited
Dec 1, 2021
Insert cell
Insert cell
Insert cell
parse
=
(
list
)
=>
list
.
split
(
'\n'
)
.
map
(
n
=>
parseInt
(
n
)
)
Insert cell
increases
=
(
list
)
=>
{
let
count
=
0
;
for
(
let
i
=
1
;
i
<
list
.
length
;
i
++
)
{
if
(
list
[
i
]
>
list
[
i
-
1
]
)
count
++
;
}
return
count
;
}
Insert cell
increases
(
parse
(
testInput
)
)
Insert cell
Insert cell
Insert cell
increases
(
parse
(
input
)
)
Insert cell
chunkByWindows
=
(
list
)
=>
list
.
reduce
(
(
acc
,
n
,
idx
,
arr
)
=>
{
if
(
idx
>
arr
.
length
-
3
)
return
acc
;
return
[
...
acc
,
n
+
arr
[
idx
+
1
]
+
arr
[
idx
+
2
]
]
;
}
,
[
]
)
Insert cell
chunkByWindows
(
parse
(
testInput
)
)
Insert cell
increases
(
chunkByWindows
(
parse
(
testInput
)
)
)
Insert cell
Insert cell
increases
(
chunkByWindows
(
parse
(
input
)
)
)
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
testInput
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
parse
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
increases
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
input
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
chunkByWindows
Add comment
Copy import
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML