Platform
Resources
Pricing
Sign in
Get started
Andreas Plesch
Workspace
Fork
Published
aoc2019
By
Andreas Plesch
Edited
Dec 14, 2019
2 forks
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
program
=
puzzle
.
split
(
","
)
Insert cell
output
=
intcomp
(
program
)
.
value
Insert cell
outputXYVf
=
function
(
out
)
{
return
out
.
reduce
(
(
a
,
v
,
i
)
=>
i
%
3
==
2
?
a
.
concat
(
[
[
out
[
i
-
2
]
,
out
[
i
-
1
]
,
v
]
]
)
:
a
,
[
]
)
;
}
Insert cell
outputXYV
=
outputXYVf
(
output2
)
Insert cell
dims
=
{
let
xs
=
outputXYV
.
map
(
v
=>
v
[
0
]
)
.
sort
(
(
a
,
b
)
=>
a
-
b
)
;
let
ys
=
outputXYV
.
map
(
v
=>
v
[
1
]
)
.
sort
(
(
a
,
b
)
=>
a
-
b
)
;
return
{
origin
:
[
xs
[
0
]
,
ys
[
0
]
]
,
width
:
xs
[
xs
.
length
-
1
]
-
xs
[
0
]
+
1
,
height
:
ys
[
ys
.
length
-
1
]
-
ys
[
0
]
+
1
}
}
Insert cell
screen
=
{
let
s
=
Array
(
dims
.
height
)
.
fill
(
0
)
.
map
(
v
=>
Array
(
dims
.
width
)
.
fill
(
0
)
)
;
outputXYV
.
forEach
(
(
cell
,
i
)
=>
{
s
[
cell
[
1
]
]
[
cell
[
0
]
]
=
cell
[
2
]
;
}
)
;
return
s
}
Insert cell
blocktiles
=
screen
.
reduce
(
(
a
,
r
)
=>
a
.
concat
(
r
)
,
[
]
)
.
filter
(
v
=>
v
==
2
)
.
length
Insert cell
screentxt
=
{
const
gfx
=
{
0
:
"⬛"
,
//"░",
1
:
"⬜"
,
//"▓",
2
:
"🔶"
,
//"█",
3
:
"🚀"
,
//"▬",
4
:
"⚽"
//"O"
}
;
return
` Score: ${
output2
[
score_i
[
0
]
+
2
]
}\n`
+
screen
.
map
(
r
=>
r
.
map
(
v
=>
gfx
[
v
]
)
.
join
(
""
)
)
.
join
(
"\n"
)
;
}
Insert cell
screendiv
=
html
`<div>
<pre style="font-size:6px;line-height:1.2; color: lightgreen; background-color: black">${
screentxt
}</pre>
</div>
`
Insert cell
Insert cell
Insert cell
Insert cell
output2
=
{
let
i
=
10000
,
out
=
intcomp
(
program2
)
,
wait
=
100
;
while
(
wait
--
)
{
yield
out
.
value
}
while
(
i
--
)
{
out
=
intcomp
(
out
.
mem
,
[
0
]
)
;
// no paddle control
yield
out
.
value
;
}
yield
out
.
value
}
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
puzzle
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
puzzle2
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
program
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
output
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
outputXYVf
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
outputXYV
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dims
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
screen
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
blocktiles
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
screentxt
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
screendiv
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
program2
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
output2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
score_i
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
intcomp
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML