#C219. Return to Origin
Return to Origin
Return to Origin
Given a string representing the moves of a robot, determine if the robot returns to its original position after executing all the moves.
The move string consists of the characters 'U' (up), 'D' (down), 'L' (left), and 'R' (right). The robot starts at the origin (0, 0) and each move changes its coordinates by one unit in the corresponding direction.
In other words, if after executing all moves the coordinates (x, y) satisfy the conditions \( x = 0 \) and \( y = 0 \), then the robot returns to its starting position. Otherwise, it does not.
inputFormat
The input is read from the standard input (stdin). It consists of a single line containing a non-empty string moves where each character is one of 'U', 'D', 'L', or 'R'.
outputFormat
Output a single line to the standard output (stdout) containing either True
if the robot returns to the origin, or False
otherwise.
True