Fatal nuisance

Report a typo

The Mario brothers know all about pipes. "Channels are the same as pipes", they thought and wrote a program that sends their names to the channel and then receives each of them.

Luigi sent the names to the channel, and Mario waited for data from the other side of the channel. However, something went wrong.

Help the plumber brothers use the channels in Go and avoid fatal mistakes. You can do it in any way!

Sample Input 1:

Sample Output 1:

Hello, Luigi Mario!
Hello, Mario Mario!
Write a program in Go
package main

import "fmt"

// make it great famous brothers
func main() {
ch := make(chan string)

luigi(ch)
mario(ch)
}

// DO NOT change brother's functions
func luigi(ch chan<- string) {
ch <- "Luigi"
ch <- "Mario"
}

func mario(ch <-chan string) {
fmt.Printf("Hello, %s Mario!\n", <-ch)
fmt.Printf("Hello, %s Mario!\n", <-ch)
}
___

Create a free account to access the full topic