Platform
Resources
Pricing
Sign in
Get started
senritsu
Workspace
Fork
Public
Advent of Code 2022
By
senritsu
Edited
Oct 9, 2023
Advent of Code 2022
Advent of Code 2022
Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8
Day 9
Day 10
Day 11
Day 12
Day 13
Day 14
Insert cell
Insert cell
adventOfCodeHeader
(
2022
,
14
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
drawPath
=
R
.
curry
(
(
map
,
fill
,
path
)
=>
)
Insert cell
buildMap
=
bounds
=>
{
const
size
=
bounds
.
map
(
(
[
a
,
b
]
)
=>
b
-
a
+
1
)
return
{
bounds
:
bounds
,
size
,
data
:
new
Array
(
size
[
0
]
*
size
[
1
]
)
.
fill
(
null
)
}
}
Insert cell
parsePath
=
R
.
pipe
(
R
.
split
(
' -> '
)
,
R
.
map
(
R
.
pipe
(
R
.
split
(
','
)
,
R
.
map
(
parseInt
)
)
)
)
Insert cell
parsePaths
=
R
.
pipe
(
R
.
split
(
'\n'
)
,
R
.
map
(
parsePath
)
)
Insert cell
getBounds
=
R
.
pipe
(
x
=>
x
.
flat
(
)
,
R
.
transpose
,
R
.
map
(
x
=>
[
Math
.
min
(
...
x
)
,
Math
.
max
(
...
x
)
]
)
,
R
.
transpose
)
Insert cell
isOutOfBounds
=
R
.
curry
(
(
bounds
,
v
)
=>
v
.
some
(
(
c
,
i
)
=>
c
<
bounds
[
0
]
[
i
]
||
c
>
bounds
[
1
]
[
i
]
)
)
Insert cell
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
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
exampleInput
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sandStart
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
Edit
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
buildMap
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
parsePath
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
parsePaths
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getBounds
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
isOutOfBounds
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
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML