-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaypoint.yuk
executable file
·57 lines (48 loc) · 1.09 KB
/
waypoint.yuk
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/local/bin/awful
!fun :rotate-left &x &y $degrees
!if :ge $degrees i180
:sub °rees i180
:set &x :sub i0 $x
:set &y :sub i0 $y
!fi
!if :ge $degrees i90
:sub °rees i90
:set &temp $x
:set &x :sub i0 $y
:set &y $temp
!fi
!nuf
!fun :rotate-right &x &y $degrees
:rotate-left &x &y :sub i360 $degrees
!nuf
:set &sx &sy i0
:set &wx i10
:set &wy i1
!while :not :stdin-eof
:set &line s''
:readln &line
:set &instruction :str-sub $line i1 i1
:set &argument :mkint :str-sub $line i2
!if :eq &instruction s'N'
:add &wy &argument
!elif :eq &instruction s'E'
:add &wx &argument
!elif :eq &instruction s'S'
:sub &wy &argument
!elif :eq &instruction s'W'
:sub &wx &argument
!elif :eq &instruction s'L'
:rotate-left &wx &wy $argument
!elif :eq &instruction s'R'
:rotate-right &wx &wy $argument
!elif :eq &instruction s'F'
:add &sx :mul $wx $argument
:add &sy :mul $wy $argument
!else
:writeln s'Unrecognized instruction: "' $instruction $argument ss"s
:exit i1
!fi
!done
:writeln s'x: ' $sx
:writeln s'y: ' $sy
:writeln s'dist: ' :add ( :abs $sx | :abs $sy )