|
A simple line drawing program uses a blank 20 x 20 pixel canvas and
a directional cursor that starts at the upper left corner pointing
straight down. The upper left corner of the canvas is at (0, 0) and the
lower right corner is at (19, 19). You are given a String[], commands,
each element of which contains one of two possible commands. A command
of the form "FORWARD x" means that the cursor should move forward by x
pixels. Each pixel on its path, including the start and end points, is
painted black. The only other command is "LEFT", which means that the
cursor should change its direction by 90 degrees counterclockwise. So,
if the cursor is initially pointing straight down and it receives a
single "LEFT" command, it will end up pointing straight to the right.
Execute all the commands in order and return the resulting 20 x 20
pixel canvas as a String[] where character j of element i represents
the pixel at (i, j). Black pixels should be represented as uppercase
'X' characters and blank pixels should be represented as '.'
characters. |