Suppose you have a strip of paper and are given instructions to fold the paper in one of two ways: an upper fold, where the right end of the paper is brought over to the top of the left end; and a lower fold, where the right end of the paper is brought below the left end. The diagram below illustrates both types of folds.
Original strip
o---------------->
Upper fold
<--------\
o--------/
Lower fold
o--------\
<--------/
Now, after meticulously folding the strip several times, you are asked
to unfold it by making a 90 degree angle at each crease. The example
below shows the result of an upper fold, followed by a lower fold and
then an unfolding.
Upper...
<----------------\
o----------------/
followed by lower...
<---------\
o--------\ \
/--------/ /
\---------/
and then unfolded
(1,0) (2,0)
o--------+ +
(0,0) | |
| |
| |
(1,-1) +--------+ (2,-1)
If the left end of the folded strip is placed at the origin (0,0) and
the first right angle is at (1,0) then the following questions can be asked:
Where will the second fold be locate? Where will the third fold be located?
Where will the other end of the strip be located?
Input: a sequence of letters 'U' and 'L' corresponding to folds of type upper and lower performed from left to right.
Output: a list of coordinates indicating fold corners in sequence from the origin (leftmost piece of the paper) and the current direction of the paper (-1 means down or left, 1 means up or right, 0 means no change).