Jerry's best friends ever!

Report a typo

Jerry Seinfeld is trying to implement a function createSet that will create and return the set bestFriends with the name of his 3 best friends. However, he has created a regular map instead of a set!

Can you help Jerry fix his code so the bestFriends map turns into a bool type value set?

Sample Input 1:

George Costanza

Sample Output 1:

George Costanza is one of Jerry's best friends
Write a program in Go
package main

import (
"fmt"
"log"
)

func createSet() map[string]bool {
// fix the type of the bestFriends map values.
bestFriends := map[string]string {
"George Costanza": "true",
"Elaine Benes": "true",
"Cosmo Kramer": "true",
}

return bestFriends // do not delete this line!
}

// DO NOT delete or modify the contents of the main function!
func main() {
mySlice := make([]string, 2)
fmt.Scanln(&mySlice[0], &mySlice[1])

bfSet := createSet()

if !bfSet[mySlice[0]+" "+mySlice[1]] {
log.Fatal("bool type sets should have 'true' as map values!")
}
fmt.Println(mySlice[0], mySlice[1], "is one of Jerry's best friends")
}
___

Create a free account to access the full topic