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.
32 lines
307 B
32 lines
307 B
5 years ago
|
package main
|
||
|
|
||
5 years ago
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
)
|
||
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(os.Args) == 2 {
|
||
|
fmt.Println(solve(os.Args[1]))
|
||
5 years ago
|
}
|
||
|
}
|