Question: Write a Go program to do the following: Reads problems from STDIN as a list of positive integers separated by whitespace, one problem per line.

Write a Go program to do the following:

Reads problems from STDIN as a list of positive integers separated by whitespace, one problem per line. Output a solution to the problem to STDOUT that makes the equation valid. Each +, -, *, /, and = must be passed by one space on each side. If no solution is found simply output a blank line to STDOUT. Errors in parsig STDIN exit with a non-zero status code after writing the error to STDERR. Your program must use recursion to search for solutions

use only Go standard library.

Example Output

$ echo "3 1 2" | go run . 3-1=2 $ echo "5 4 2 22" | go run . 5*4+2=22 $ (echo "3 1 2" && echo "9 2 18") | go run . 3-1=2 9*2=18 $ echo "6 2 3 4" | go run . 6*2/3=4 $ go run . < testdata/basic.txt 3 - 1 = 2 9 + 0 = 9 2 * 3 = 6 4 + 5 = 9 4 + 5 + 6 = 15 2 + 3 + 1 = 6

With multiple solutions it looks like:

$ echo "7 3 3 7" | go run . -all 7+3-3=7, 7-3+3=7, 7*3/3=7 $ go run . -all < testdata/basic.txt 3 - 1 = 2 9 + 0 = 9, 9 - 0 = 9 2 * 3 = 6 4 + 5 = 9 4 + 5 + 6 = 15 2 + 3 + 1 = 6, 2 * 3 * 1 = 6, 2 * 3 / 1 = 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!