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.
31 lines
803 B
31 lines
803 B
5 years ago
|
## 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:
|
||
5 years ago
|
|
||
|
- U - up
|
||
5 years ago
|
- D - down
|
||
|
- R - right
|
||
|
- L - left
|
||
|
|
||
5 years ago
|
If the number of arguments is not 1, output nothing.
|
||
5 years ago
|
|
||
|
### Usage
|
||
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ go build
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./main "UD"
|
||
5 years ago
|
true
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./main "LL"
|
||
5 years ago
|
false
|
||
|
```
|
||
|
|
||
|
In first case, the robot moves up and the down. So, it returned back to its origin position.
|
||
|
|
||
5 years ago
|
In second example, the robot moves twice to the left. It is 2 positions left from its origin, so the program outputs false.
|