import java.io.*; import java.awt.*; public class edge { public static void main(String[] args) throws Exception { BufferedReader input = new BufferedReader(new FileReader("edge.in")); String value = ""; while((value = input.readLine()) != null) { fold(value); System.out.println("stroke"); System.out.println("showpage"); } input.close(); } public static void fold(String input) { System.out.println("300 420 moveto"); int direction = 2; Point position = move(300, 420, direction, true); int xPos = (int)position.getX(); int yPos = (int)position.getY(); char[] commands = input.toCharArray(); for(int i = 0; i < commands.length; i++) { if(commands[i] == 'A') { direction = changeDirection(direction, CLOCKWISE); } else if(commands[i] == 'V') { direction = changeDirection(direction, COUNTER_CLOCKWISE); } position = move(xPos, yPos, direction, true); xPos = (int)position.getX(); yPos = (int)position.getY(); } } public static final int CLOCKWISE = 1; public static final int COUNTER_CLOCKWISE = 2; public static Point move(int xPos, int yPos, int direction, boolean line) { switch(direction) { case(1) : { yPos = yPos + 10; break; } case(2) : { xPos = xPos + 10; break; } case(3) : { yPos = yPos - 10; break; } case(4) : { xPos = xPos - 10; break; } } if(line) System.out.println(xPos + " " + yPos + " lineto"); else System.out.println(xPos + " " + yPos + " moveto"); return(new Point(xPos, yPos)); } public static int changeDirection(int direction, int change) { if(change == CLOCKWISE) { direction++; if(direction > 4) direction = 1; } else if(change == COUNTER_CLOCKWISE) { direction--; if(direction < 1) direction = 4; } return(direction); } }