mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
800 B
800 B
robottoorigin
Instructions
There is a robot at position (0, 0) at 2D map.
Write a program, that outputs true
if robot ends up at the origin (0, 0) after a sequence of moves, otherwise false
. \n
should be in the end of line.
Sequence of moves is a string, which characters state for movement direction:
- U - up
- D - down
- R - right
- L - left
If the number of arguments is not 1, output \n
.
Usage
student@ubuntu:~/[[ROOT]]/test$ go build
student@ubuntu:~/[[ROOT]]/test$ ./main "UD"
true
student@ubuntu:~/[[ROOT]]/test$ ./main "LL"
false
In first case, the robot moves up and the down. So, it returned back to its origin position.
In second example, the robot moves twice to the left. It is 2 positions left from its origin, so the program outputs false.