Platform
Resources
Pricing
Sign in
Get started
George Hotelling
Workspace
Fork
Public
Advent of Code 2022
By
George Hotelling
Edited
Dec 6, 2022
Insert cell
Insert cell
Insert cell
unique
=
arr
=>
[
...
new
Set
(
arr
)
]
Insert cell
startOfSignal
=
(
input
)
=>
{
const
buffer
=
[
input
[
0
]
,
input
[
1
]
,
input
[
2
]
]
;
for
(
let
i
=
3
;
i
<
input
.
length
;
i
++
)
{
buffer
.
push
(
input
[
i
]
)
;
if
(
unique
(
buffer
)
.
length
===
4
)
return
i
+
1
;
buffer
.
shift
(
)
;
}
}
Insert cell
startOfSignal
(
testInputs
[
0
]
)
Insert cell
testInputs
.
map
(
startOfSignal
)
Insert cell
Insert cell
startOfSignal
(
input
)
Insert cell
startOfMessage
=
(
input
)
=>
{
const
buffer
=
input
.
substring
(
0
,
13
)
.
split
(
""
)
;
for
(
let
i
=
13
;
i
<
input
.
length
;
i
++
)
{
buffer
.
push
(
input
[
i
]
)
;
if
(
unique
(
buffer
)
.
length
===
14
)
return
i
+
1
;
buffer
.
shift
(
)
;
}
return
buffer
;
}
Insert cell
startOfMessage
(
testInputs
[
0
]
)
Insert cell
testInputs
.
map
(
startOfMessage
)
Insert cell
startOfMessage
(
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
testInputs
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
unique
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
startOfSignal
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
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
startOfMessage
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML