#K92497. Valid Circle Moves
Valid Circle Moves
Valid Circle Moves
You are given a string representing a sequence of moves on a 2D grid. Each character in the string is one of 'U' (up), 'D' (down), 'L' (left), or 'R' (right). The task is to determine whether these moves form a valid circle on the grid, i.e. whether starting from the origin \((0,0)\) you return to the origin after performing all the moves.
A valid circle satisfies the condition:
\[ x = 0 \text{ and } y = 0 \]
Print True
if the moves result in a valid circle, otherwise print False
.
inputFormat
The input consists of a single string (read from stdin) which only contains the characters 'U', 'D', 'L', and 'R'.
outputFormat
Output a single line to stdout: True
if the moves form a valid circle, and False
otherwise.
UDLR
True