Pangram checker: Difference between revisions
Content added Content deleted
(Added Rust implementation of Pangram checker) |
(→{{header|Go}}: Use bit fiddling, since it makes the code shorter and uses less memory) |
||
Line 1,123: | Line 1,123: | ||
func pangram(s string) bool { |
func pangram(s string) bool { |
||
var missing uint32 = (1 << 26) - 1 |
|||
for _, c := range s { |
|||
var index uint32 |
|||
for _, c := range s { |
|||
if 'a' <= c && c <= 'z' { |
|||
index = uint32(c - 'a') |
|||
} else if 'A' <= c && c <= 'Z' { |
|||
index = uint32(c - 'A') |
|||
} |
|||
⚫ | |||
c -= 'a' |
|||
continue |
|||
⚫ | |||
} |
|||
if c < 'A' || c > 'Z' { |
|||
continue |
|||
missing &^= 1 << index |
|||
} |
|||
if missing == 0 { |
|||
c -= 'A' |
|||
⚫ | |||
} |
|||
} |
|||
if !rep[c] { |
|||
} |
|||
if count == 25 { |
|||
return false |
|||
} |
|||
rep[c] = true |
|||
count++ |
|||
} |
|||
} |
|||
⚫ | |||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |