#K65042. Final Coordinates Calculation
Final Coordinates Calculation
Final Coordinates Calculation
You are given a string that represents a sequence of moves. Each character in the string is one of the following:
U
: move upward, which increments the y-coordinate by 1.D
: move downward, which decrements the y-coordinate by 1.L
: move left, which decrements the x-coordinate by 1.R
: move right, which increments the x-coordinate by 1.
The starting point is at (0, 0). If you denote the final coordinates by \( (x, y) \), then they are computed as:
\( x = \text{number of } R - \text{number of } L \) and \( y = \text{number of } U - \text{number of } D \).
Your task is to compute and output the final coordinates after processing all moves.
inputFormat
A single line string representing a sequence of moves (each character is either 'U', 'D', 'L', or 'R').
outputFormat
Two space-separated integers representing the final x and y coordinates.## sample
UUDDLRLR
0 0