Merge pull request #299 from marekchen/patch-1

fix start with or end with space,word count error
This commit is contained in:
无闻
2016-12-21 06:45:05 -05:00
committed by GitHub

View File

@@ -31,7 +31,6 @@ func main() {
func Counters(input string) { func Counters(input string) {
nrchars += len(input) - 2 // -2 for \r\n nrchars += len(input) - 2 // -2 for \r\n
// count number of spaces, nr of words is +1 nrwords += len(strings.Fields(input))
nrwords += strings.Count(input, " ") + 1
nrlines++ nrlines++
} }