Skip to content

Instantly share code, notes, and snippets.

@videlalvaro
Last active September 25, 2018 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlalvaro/29e7c71466bac663f3b86f1ce4dc9066 to your computer and use it in GitHub Desktop.
Save videlalvaro/29e7c71466bac663f3b86f1ce4dc9066 to your computer and use it in GitHub Desktop.
single_letter.go
func RuneCount(b []byte) int {
i, n := 0, 0
for i < len(b) {
if b[i] < RuneSelf {
i++
} else {
_, size := DecodeRune(b[i:])
i += size
}
n++
}
return n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment