Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P2122
synthace.js
Active
Public
Actions
Authored by
epriestley
on Aug 8 2019, 7:05 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F6702977: raw.txt
Aug 8 2019, 7:05 PM
2019-08-08 19:05:29 (UTC+0)
Subscribers
None
let
x
=
parseInt
(
GRID_SIZE
/
2
);
let
y
=
parseInt
(
GRID_SIZE
/
2
);
function
jumpTo
(
instructions
,
px
,
py
)
{
moveRelative
(
instructions
,
px
-
x
,
py
-
y
);
}
function
moveRelative
(
instructions
,
rx
,
ry
)
{
instructions
.
push
({
moveX
:
rx
,
moveY
:
ry
});
x
=
x
+
rx
;
y
=
y
+
ry
;
}
function
crawlTo
(
instructions
,
px
,
py
)
{
while
(
px
<
x
)
{
moveRelative
(
instructions
,
-
1
,
0
);
}
while
(
px
>
x
)
{
moveRelative
(
instructions
,
+
1
,
0
);
}
while
(
py
<
y
)
{
moveRelative
(
instructions
,
0
,
-
1
);
}
while
(
py
>
y
)
{
moveRelative
(
instructions
,
0
,
+
1
);
}
}
(()
=>
{
const
GRID_SIZE
=
31
;
const
instructions
=
[];
for
(
var
ring
=
0
;
ring
<=
15
;
ring
++
)
{
var
sx
=
ring
;
var
sy
=
ring
;
var
tx
=
(
GRID_SIZE
-
ring
)
-
1
;
var
ty
=
(
GRID_SIZE
-
ring
)
-
1
;
jumpTo
(
instructions
,
sx
,
sy
);
crawlTo
(
instructions
,
tx
,
sy
);
crawlTo
(
instructions
,
tx
,
ty
);
crawlTo
(
instructions
,
sx
,
ty
);
crawlTo
(
instructions
,
sx
,
sy
+
1
);
}
return
instructions
;
})();
Event Timeline
epriestley
created this paste.
Aug 8 2019, 7:05 PM
2019-08-08 19:05:29 (UTC+0)
Log In to Comment