fork download
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "strings"
  6. )
  7.  
  8. func main() {
  9. arr := make(map[string]int)
  10. text := "wwwwdddeeeehhhh"
  11. for i := 0; i < len(text); i++ {
  12. arr[string(text[i])] = strings.Count(text, string(text[i]))
  13. }
  14. for word, count := range arr {
  15. fmt.Println(word, count)
  16. }
  17. }
  18.  
  19.  
Success #stdin #stdout 0s 3076KB
stdin
Standard input is empty
stdout
w 4
d 3
e 4
h 4