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
384 B
32 lines
384 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
5 years ago
|
func solve(s string) int {
|
||
5 years ago
|
var count, countC, countD int
|
||
5 years ago
|
for _, r := range s {
|
||
5 years ago
|
if r == 'C' {
|
||
5 years ago
|
countC++
|
||
5 years ago
|
} else if r == 'D' {
|
||
5 years ago
|
countD++
|
||
|
}
|
||
|
if countC == countD {
|
||
|
count++
|
||
|
countC = 0
|
||
|
countD = 0
|
||
|
}
|
||
|
}
|
||
|
return count
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
args := os.Args[1:]
|
||
5 years ago
|
if len(args) == 1 {
|
||
|
result := solve(args[0])
|
||
|
fmt.Println(result)
|
||
5 years ago
|
}
|
||
|
}
|