#K64382. Return to Origin: Car Movement Check
Return to Origin: Car Movement Check
Return to Origin: Car Movement Check
You are given a string that represents a sequence of moves made by a car on a 2D plane. Each move in the string is a character among N
(north), S
(south), E
(east), and W
(west). Starting from the origin \((0,0)\), the car moves as follows:
- N: Increase the \(y\)-coordinate by 1.
- S: Decrease the \(y\)-coordinate by 1.
- E: Increase the \(x\)-coordinate by 1.
- W: Decrease the \(x\)-coordinate by 1.
Your task is to determine whether the car returns to the origin \((0,0)\) after executing all moves. Print True
if it does and False
otherwise.
inputFormat
A single line from standard input containing a string of characters, each representing a move.
Note: The string may be empty.
outputFormat
Output a single line to standard output containing True
if the car returns to the origin \((0,0)\), otherwise output False
.
NS
True