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

  Design a protocol by which two mutually suspicious parties

q1. what are some other levels of protection that users might want to apply to code or data in addition to the common

  What is the rationale for refactoring in agile development

You identified dirty code when working on separate task (While working on a task you have identified some dirty code from some other task.

  How the concept help explain the behavior

Choose three concepts from social and/or sociocognitive psychology (i.e. groupthink, group polarization, deindividuation, in-group bias, obedience, conformity.

  Write a main that sets an unsigned to some value

Write a main that sets an unsigned to some value, passes the address of the unsigned to bit, and then outputs the 32 bits of the unsigned, high-order bit first.

  Generate all permutations of an integer array of size n

Write a nonrecursive function in c++ that generates all permutations of an integer array of size N, N can be any length, it is a parameter.

  Create an infographic using an infographic maker

Create an infographic using an infographic maker, such as Piktochart, Venngage, or Canva, displaying an organization chart showing the following.

  General approach is to encourage timely communication news

The general approach is to encourage timely communication of news (positive or negative) to project stakeholders. However, can you envisage situations where it may be required , or even advantageous, for project management to suppress the dissemin..

  Discuss ict4d applications in core sectors of development

CS 120 New Jersey City University discuss ICT4D Applications in Core Sectors of Development and discuss opportunities and challenges of Social Media in Higher

  How to design the physical implementation

Setup the database using Microsoft Access. how to Design the physical implementation.

  Higher order thinking - partial products method

CS 213 University of Notre Dame Explain how the standard algorithm, where you regroup in each step, and the partial products method are alike. Explain how they

  Display the names and salaries of employees

Find the mean(averages) salary and display the names and salaries of employees who earn within a range of $5000 from the mean.

  Create two more functions

Create two more functions. The first function will discover if there were upper case letters in the single letter user input.

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