Write a go program to reads problems from stdin

Assignment Help Computer Engineering
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

Reference no: EM133368683

Questions Cloud

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?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd