Skip to content

Commit e071e7e

Browse files
committed
AbCheck resolved
1 parent 8d766c1 commit e071e7e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/easy/AbCheck.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"regexp"
6+
)
7+
8+
// ABCheck takes the str parameter and returns true if the characters a and b are separated by exactly 3 places anywhere in the string at least once
9+
func ABCheck(str string) string {
10+
re := regexp.MustCompile(`(a...b|b...a)`)
11+
return fmt.Sprintf("%t", re.MatchString(str))
12+
}
13+
14+
func main() {
15+
result1 := ABCheck("lane borrowed")
16+
fmt.Println(result1)
17+
result2 := ABCheck("australia")
18+
fmt.Println(result2)
19+
}

0 commit comments

Comments
 (0)