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