tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View 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
}