

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
Not enough gems
Cost: 6 gems
1: Maps
incomplete
2: Mutations
incomplete
3: Key Types
incomplete
4: Count Instances
incomplete
5: Effective Go
incomplete
6: Nested
incomplete
7: Distinct Words
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Maps can contain maps, creating a nested structure. For example:
map[string]map[string]int
map[rune]map[string]int
map[int]map[string]map[string]intBecause Textio is a glorified customer database, we have a lot of internal logic for sorting and dealing with customer names.
Complete the getNameCounts function. It takes a slice of strings names and returns a nested map. The parent map's keys are all the unique first characters (see runes) of the names. The nested maps' keys are all the names themselves, and the values are the counts of each name.
For example:
billy
billy
bob
joeCreates the following nested map:
b: {
billy: 2,
bob: 1
},
j: {
joe: 1
}The test suite is not printing the map you're returning directly, but instead checking a few specific keys.
You can convert a string into a slice of runes as follows:
runes := []rune(word)Don't worry about normalizing the case of the strings. Uppercase and lowercase letters will be treated as different.