Quick actions

cmd+k|ctrl+k

Navigation

Languages

100knock #03

Snippet info

Language

Go

Visibility

public

Author

re3turn

Created

2018-05-09T05:06:27Z

Updated

2018-05-09T15:25:19Z

package main

import (
	"fmt"
	"strings"
	"unicode/utf8"
)

func countRunes(words []string) []rune {
	runes := make([]rune, len(words))
	for index, runeValue := range words {
		runes[index] = rune(utf8.RuneCountInString(runeValue))
	}

	return runes
}

func main() {
	word := "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."

	word = strings.Replace(word, ",", "", -1)
	word = strings.Replace(word, ".", "", -1)
	words := strings.Split(word, " ")

	fmt.Println(countRunes(words))
}
INFO