You have a machine that cuts glass panes using a robotic arm with a diamond point at the end.
The input to the machine is a rectangular piece of glass with width W and height H.
The machine has a coordinate system with point (0,0) in one corner of the glass pane and (W,H) in the opposite corner.
In the beginning, the diamond point is positioned at (startx,starty).
Then the machine executes a given program.
The program is given as a String[] program. Concatenate the elements of program to get one long string that describes the program. Each character in the program describes one movement of the diamond point: 'L' decreases its x-coordinate, 'R' increases its x-coordinate, 'U' decreases its y-coordinate and 'D' increases its y-coordinate by 1.
During all movements, the diamond point cuts the glass.
Once the cutting is over, the glass may fall apart into multiple pieces. Compute and return their count.
|