A Song of Ice and Fire

Report a typo

Your friend George Martin has completed the manuscript for part 7 of "A Song of Ice and Fire". But when he re-read it, he realized that he had mixed up the continent's name. Now, in his novel, instead of "Westeros" appeared "Misteros". We urgently need to replace all the names in the text.

This problem uses the bufio and os packages to read a string with white spaces or tabs from the input. To solve this task, you don't need to know how the bufio/os packages work; your only objective is to use the correct function from the strings package that replaces substrings.

Sample Input 1:

One day, the noble Jacques, who lived in Misteros, decided to move to another continent. But Misteros didn't want to let him go.

Sample Output 1:

One day, the noble Jacques, who lived in Westeros, decided to move to another continent. But Westeros didn't want to let him go.
Write a program in Go
package main

import (
"bufio"
"fmt"
"os"
"strings"
)

const (
westeros = "Westeros"
misteros = "Misteros"
)

// Which function from the `strings` package is used to replace a string?
func wordReplacer(novel, wrong, correct string) string {
return ?.?(?, ?, ?)
}

// DO NOT delete or modify the contents of the main function!
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
fmt.Println(wordReplacer(scanner.Text(), misteros, westeros))
}
___

Create a free account to access the full topic