Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Pangram-checker/Go/pangram-checker.go
Normal file
37
Task/Pangram-checker/Go/pangram-checker.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
for _, s := range []string{
|
||||
"The quick brown fox jumps over the lazy dog.",
|
||||
`Watch "Jeopardy!", Alex Trebek's fun TV quiz game.`,
|
||||
"Not a pangram.",
|
||||
} {
|
||||
if pangram(s) {
|
||||
fmt.Println("Yes:", s)
|
||||
} else {
|
||||
fmt.Println("No: ", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func pangram(s string) bool {
|
||||
var missing uint32 = (1 << 26) - 1
|
||||
for _, c := range s {
|
||||
var index uint32
|
||||
if 'a' <= c && c <= 'z' {
|
||||
index = uint32(c - 'a')
|
||||
} else if 'A' <= c && c <= 'Z' {
|
||||
index = uint32(c - 'A')
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
missing &^= 1 << index
|
||||
if missing == 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue