tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
43
Task/Pangram-checker/Go/pangram-checker.go
Normal file
43
Task/Pangram-checker/Go/pangram-checker.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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 rep [26]bool
|
||||
var count int
|
||||
for _, c := range s {
|
||||
if c >= 'a' {
|
||||
if c > 'z' {
|
||||
continue
|
||||
}
|
||||
c -= 'a'
|
||||
} else {
|
||||
if c < 'A' || c > 'Z' {
|
||||
continue
|
||||
}
|
||||
c -= 'A'
|
||||
}
|
||||
if !rep[c] {
|
||||
if count == 25 {
|
||||
return true
|
||||
}
|
||||
rep[c] = true
|
||||
count++
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue