Platform
Resources
Pricing
Sign in
Get started
Visnu Pitiyanuvath
Workspace
Fork
Published
Advent of Code 2020
By
Visnu Pitiyanuvath
Edited
Dec 17, 2020
1 fork
1 star
Advent of Code 2020
Day 1: Report Repair
Day 2: Password Philosophy
Day 3: Toboggan Trajectory
Day 4: Passport Processing
Day 5: Binary Boarding
Day 6: Custom Customs
Day 7: Handy Haversacks
Day 8: Handheld Halting
Day 9: Encoding Error
Day 10: Adapter Array
Day 11: Seating System
Day 12: Rain Risk
Day 13: Shuttle Search
Day 14: Docking Data
Day 15: Rambunctious Recitation
Day 16: Ticket Translation
Day 17: Conway Cubes
Day 18: Operation Order
Day 19: Monster Messages
Day 25: Combo Breaker
Advent of Code Leaderboard 2020
Insert cell
Insert cell
Insert cell
function
*
neighbors
(
[
x
,
y
,
z
,
w
]
)
{
for
(
let
dx
of
[
-
1
,
0
,
1
]
)
for
(
let
dy
of
[
-
1
,
0
,
1
]
)
for
(
let
dz
of
[
-
1
,
0
,
1
]
)
for
(
let
dw
of
[
-
1
,
0
,
1
]
)
if
(
dx
!==
0
||
dy
!==
0
||
dz
!==
0
||
dw
!==
0
)
yield
[
x
+
dx
,
y
+
dy
,
z
+
dz
,
w
+
dw
]
}
Insert cell
function
tick
(
cells
)
{
let
counts
=
{
}
for
(
const
cell
of
cells
)
for
(
const
n
of
neighbors
(
cell
.
split
(
','
)
.
map
(
Number
)
)
)
counts
[
n
]
=
(
counts
[
n
]
||
0
)
+
1
let
next
=
new
Set
(
)
for
(
const
[
cell
,
count
]
of
Object
.
entries
(
counts
)
)
if
(
count
===
3
||
(
count
==
2
&&
cells
.
has
(
cell
)
)
)
next
.
add
(
cell
)
return
next
}
Insert cell
seed
=
new
Set
(
input
.
trim
(
)
.
split
(
'\n'
)
.
flatMap
(
(
l
,
x
)
=>
l
.
split
(
''
)
.
map
(
(
v
,
y
)
=>
v
===
'#'
?
[
x
,
y
,
0
,
0
]
:
null
)
)
.
filter
(
d
=>
d
)
.
map
(
String
)
)
Insert cell
fps
=
5
Insert cell
zoom
=
10
Insert cell
alive
=
{
let
cells
=
seed
for
(
let
n
=
0
;
n
<
6
;
n
++
)
{
yield
Promises
.
tick
(
1000
/
fps
,
cells
=
tick
(
cells
)
)
}
}
Insert cell
// alive = {
// let cells = this || seed
// while (true) {
// if (fps === 0)
// return yield cells
// yield Promises.tick(1000/fps, cells = tick(cells))
// }
// }
Insert cell
Insert cell
d3
=
require
(
'd3@6'
)
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
neighbors
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
tick
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
seed
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fps
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
zoom
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
alive
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
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML