Under construction

Still being built. Things may change

Edge

Time limit1sMemory limit128 MB

Summary
Given a string of A (clockwise) and V (counter-clockwise) turns, emit PostScript line commands tracing a unit-step path from a fixed start point.
Level

Easy3 of 10

Topics
Simulation, Implementation, Geometry
Solved
No attempts yet

Problem

To fit inside small packaging, the instruction sheet that ships with a product must be folded until it is small enough. Assume the sheet is rectangular and is only folded along lines parallel to its (initially) shorter edge. Each fold can be made in one of two directions: either the top surfaces of the sheet are brought together, or the bottom surfaces are. In both cases the two parts on either side of the fold line are laid neatly on top of each other, and we ignore any change in thickness.

After several folds we may unfold the sheet and look at its longer edge, holding it so that it appears as a one-dimensional curve — a concatenation of line segments. Moving along this curve in a fixed direction, every place where the sheet was folded is classified as either type A, a clockwise turn, or type V, a counter-clockwise turn. Given such a sequence of classifications, draw the longer edge of the sheet, making a 90-degree turn at each equidistant fold point.

Input

The input contains several test cases, one per line. Each line is a nonempty string of the characters A and V describing the longer edge of one sheet. The length of each string is less than 200. The input ends at end of file, immediately after the last test case.

Output

For each test case, output a PostScript drawing of the edge, one command per line.

Begin every drawing at the point (300, 420) with the command 300 420 moveto. The first turning point is at (310, 420), written as 310 420 lineto. Then, for each character of the input string, make a clockwise turn for A or a counter-clockwise turn for V, and emit an x y lineto command for the next turning point. Consecutive turning points are always 10 units apart. Do not forget the final endpoint of the edge, and finish each test case with the commands stroke and showpage.

You can view such a drawing with the gv PostScript interpreter, optionally after converting it with the ps2ps utility.

Examples3

  1. Example 1

    Input
    V
    AVV
    
    Expected output
    300 420 moveto
    310 420 lineto
    310 430 lineto
    stroke
    showpage
    300 420 moveto
    310 420 lineto
    310 410 lineto
    320 410 lineto
    320 420 lineto
    stroke
    showpage
    
  2. Example 2

    Input
    A
    
    Expected output
    300 420 moveto
    310 420 lineto
    310 410 lineto
    stroke
    showpage
    
  3. Example 3

    Input
    V
    
    Expected output
    300 420 moveto
    310 420 lineto
    310 430 lineto
    stroke
    showpage