Description
Give a string of the form 'path {....}' where the text inside the
braces is a sequence of one-byte codes used to describe the motion
of a robot. The following table lists valid available one-byte codes
and their corresponding actions:
| a | north
| | b | west
| | c | south
| | d | east
| | e | up
| | f | down
|
Each one-byte code may be preceded by one integer, which means
that action must be performed that number of times.
|
| Raw Input
| path {baecdf}
path {2a3be4c2d3f}
|
|
| Desired Output
| path {west;north;up;south;east;down;}
path {2north;3west;up;4south;2east;3down;}
|
|
Script and Comments
Script1 [ 1] 1{
[ 2] x
[ 3] s/^/a=north;b=west;c=south;d=east;e=up;f=down/
[ 4] x
[ 5] }
[ 6] s/\{/{\n/
[ 7] G
[ 8] :loop
[ 9] s/\n([0-9]*)(.)(.*)\2=([^;]*)/\1\4;\n\3\2=\4/
[10] t loop
[11] s/\n//
[12] s/\n.*//
| |
|