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.
29 lines
290 B
29 lines
290 B
5 years ago
|
package main
|
||
|
|
||
5 years ago
|
import "fmt"
|
||
5 years ago
|
|
||
5 years ago
|
func solve(s string) bool {
|
||
5 years ago
|
x := 0
|
||
|
y := 0
|
||
|
|
||
5 years ago
|
for _, r := range s {
|
||
|
switch r {
|
||
|
case 'L':
|
||
5 years ago
|
x--
|
||
5 years ago
|
case 'R':
|
||
5 years ago
|
x++
|
||
5 years ago
|
case 'U':
|
||
5 years ago
|
y++
|
||
5 years ago
|
case 'D':
|
||
5 years ago
|
y--
|
||
|
}
|
||
|
}
|
||
5 years ago
|
return x == 0 && y == 0
|
||
5 years ago
|
}
|
||
|
|
||
|
func main() {
|
||
5 years ago
|
if len(args) == 2 {
|
||
|
fmt.Println(solve(args[1]))
|
||
5 years ago
|
}
|
||
|
}
|