-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path520.go
More file actions
51 lines (44 loc) · 751 Bytes
/
520.go
File metadata and controls
51 lines (44 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import "fmt"
func detectCapitalUse(word string) bool {
//edge cases
if len(word) == 0 {
return true
}
// 1. all captial
f := true
for i := 0; i < len(word); i = i + 1 {
if int(word[i]) < 65 || int(word[i]) > 90 {
f = false
}
}
if f {
return true
}
//2. all not capital
f = true
for i := 0; i < len(word); i = i + 1 {
if int(word[i]) < 97 || int(word[i]) > 122 {
f = false
}
}
if f {
return true
}
//3. first capital following all not capital
if word[0] >= 65 && word[0] <= 90 {
f = true
for i := 1; i < len(word); i = i + 1 {
if int(word[i]) < 97 || int(word[i]) > 122 {
f = false
}
}
if f {
return true
}
}
return false
}
func main() {
fmt.Println("Hello, World!")
}