Platform
Resources
Pricing
Sign in
Get started
Annie Zhang
Workspace
Fork
Public
🎄 advent of code 2022
By
Annie Zhang
Edited
Dec 3, 2022
1 fork
1 star
1
Insert cell
Insert cell
Insert cell
maxCalories
=
{
let
count
=
0
;
let
max
=
0
;
for
(
const
cal
of
input
)
{
if
(
cal
.
length
===
0
)
{
max
=
Math
.
max
(
max
,
count
)
;
count
=
0
;
}
else
{
count
+=
+
cal
;
}
}
return
max
;
}
Insert cell
Insert cell
maxThreeCalories
=
{
let
count
=
0
;
const
counts
=
[
]
;
for
(
const
cal
of
input
)
{
if
(
cal
.
length
===
0
)
{
counts
.
push
(
count
)
;
count
=
0
;
}
else
{
count
+=
+
cal
;
}
}
counts
.
sort
(
(
a
,
b
)
=>
b
-
a
)
;
return
counts
[
0
]
+
counts
[
1
]
+
counts
[
2
]
;
}
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maxCalories
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
maxThreeCalories
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML