Created
September 7, 2020 08:31
-
-
Save Raghav2211/7dce7bddfacb3ffde355608f37e1ce73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"golang.org/x/tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
splitInput := strings.Split(s," ") | |
wordCount := make(map[string]int) | |
for _ , r := range splitInput { | |
wordCount[r] = wordCount[r]+1 | |
} | |
return wordCount | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment