-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShorterPath.strict
31 lines (31 loc) · 1007 Bytes
/
ShorterPath.strict
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
has target Vector2
from(path Text)
target = Vector2(path.Count("E") - path.Count("W"), path.Count("N") - path.Count("S"))
for path
if value is "N"
target.Y.Increment
if value is "S"
target.Y.Decrement
if value is "E"
target.X.Increment
if value is "W"
target.X.Decrement
GetDirections Text
ShorterPath("").GetDirections is ""
ShorterPath("NNE").GetDirections is "NNE"
ShorterPath("NNEN").GetDirections is "NNNE"
ShorterPath("SSNEWSN").GetDirections is "S"
ShorterPath("NWSE").GetDirections is ""
GetVerticalDirections + GetHorizontalDirections
GetVerticalDirections Text
ShorterPath("").GetVerticalDirections is ""
ShorterPath("NN").GetVerticalDirections is "NN"
ShorterPath("NSN").GetVerticalDirections is "N"
for target.Y
target.Y > 0 ? "N" else "S"
GetHorizontalDirections Text
ShorterPath("").GetHorizontalDirections is ""
ShorterPath("EEEW").GetVerticalDirections is "EE"
ShorterPath("WWWE").GetVerticalDirections is "WW"
for target.X
target.X > 0 ? "E" else "W"