Delete an element from a set

Report a typo

Suppose you have the cardinalPoints set; it contains various compass directions:

var cardinalPoints = map[string]bool{
    "northwest":  true,
    "north":      true,
    "northeast":  true,
    "northsouth": true,
    "east":       true,
    "southeast":  true,
    "south":      true,
    "southwest":  true,
    "west":       true,
}

Upon detailed inspection, you see that there is one invalid compass direction! Your task is to write the delete function below to delete the invalid direction from the cardinalPoints set.

Tip: There is a northwest direction and a northeast direction. However, is it possible to go in both the north and south directions at the same time?

Enter a short text
___

Create a free account to access the full topic