Platform
Resources
Pricing
Sign in
Get started
George Hotelling
Workspace
Fork
Public
Advent of Code 2022
By
George Hotelling
Edited
Dec 1, 2022
Advent of Code 2022
Day 10
Day 9
Day 8
Day 7
Day 6
Day 5
Day 4
Day 3
Day 2
Day 1
Insert cell
Insert cell
Insert cell
parse
=
(
input
)
=>
{
return
input
.
split
(
"\n\n"
)
.
map
(
(
e
)
=>
e
.
split
(
"\n"
)
.
map
(
(
n
)
=>
parseInt
(
n
)
)
)
;
}
Insert cell
parse
(
testInput
)
Insert cell
part1
=
(
input
)
=>
{
const
elves
=
parse
(
input
)
;
const
calories
=
elves
.
map
(
(
e
)
=>
e
.
reduce
(
(
a
,
b
)
=>
a
+
b
)
)
;
return
Math
.
max
.
apply
(
null
,
calories
)
;
}
Insert cell
part1
(
testInput
)
Insert cell
Insert cell
part1
(
input
)
Insert cell
part2
=
(
input
)
=>
{
const
elves
=
parse
(
input
)
;
const
calories
=
elves
.
map
(
(
e
)
=>
e
.
reduce
(
(
a
,
b
)
=>
a
+
b
)
)
;
const
sorted
=
calories
.
sort
(
(
a
,
b
)
=>
b
-
a
)
;
return
sorted
[
0
]
+
sorted
[
1
]
+
sorted
[
2
]
;
}
Insert cell
part2
(
testInput
)
Insert cell
part2
(
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
part1
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
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
part2
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