#K80612. Robot Return to Origin
Robot Return to Origin
Robot Return to Origin
You are given a string of commands where each character represents a move for a robot on a 2D plane. The valid commands are U
(up), D
(down), L
(left), and R
(right). The robot starts at the origin \((0,0)\) and moves one unit per command.
Your task is to determine if after executing all the commands, the robot returns to the origin. In other words, check whether the net horizontal and vertical displacements are both zero.
inputFormat
A single string containing the characters 'U', 'D', 'L', and 'R' representing the moves of the robot. The input is provided via standard input (stdin).
outputFormat
Output a single line containing either "True" if the robot returns to the origin, or "False" otherwise. The output should be printed to standard output (stdout).## sample
UD
True