Reference no: EM133368683
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.
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
Do you back up everything on your computer
: Do you back up everything on your computer, such as applications, data files, documents, music, and photos? What procedures do you use? Have you learned
|
Analyzes the financial condition of marriott
: analyzes the financial condition of Marriott. The introduction should be a summary of the case, the body of the report it should be split in different section
|
What is the first event in the list
: Scroll through the list of Error or Warning events, and list any that indicate a possible hardware problem. What is the first event in the list?
|
Evaluate melnyk strategy and what are the objectives
: Evaluate Melnyk's strategy. What are the objectives? What would you do if you were in hissituation, prior to the lawsuit? How do investors gather information
|
Write a go program to reads problems from stdin
: CS 143 Open University Malaysia Reads problems from STDIN as a list of positive integers separated by whitespace, one problem per line
|
Discuss which bank you would choose to patronize and explain
: You may write findings on each bank in paragraph form, or you may help to prepare a chart to include in your response. Once you have made your comparison
|
Briefly what are some benefits - modern linux architecture
: CPS 590 Ryerson University The modern Linux architecture provides Linux some benefits typically associated with micro-kernels. Briefly what are some benefits?
|
How much would you need to have in your fund when you retire
: How much would you need to have in your fund when you retire to achieve this goal? Enter your answer as a whole number of dollars.
|
What is the difference between a use case and a user story
: What is the difference between a Use Case and a User Story? In what scenario do you apply one over the other?
|