mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-30 16:48:39 +01:00
20210121
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import "strings"
|
||||
|
||||
const balloon = "balloon"
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
|
||||
func maxNumberOfBalloons(text string) int {
|
||||
nt := text
|
||||
lt := text
|
||||
end := false
|
||||
count := 0
|
||||
for {
|
||||
for _, c := range balloon {
|
||||
nt = strings.Replace(lt, string(c), "", 1)
|
||||
if nt == lt {
|
||||
end = true
|
||||
break
|
||||
}
|
||||
lt = nt
|
||||
}
|
||||
if end {
|
||||
break
|
||||
}
|
||||
count++
|
||||
}
|
||||
return count
|
||||
}
|
||||
Reference in New Issue
Block a user