Question: Write a function called max - ops - diff in R 5 RS Scheme that takes a list of magnitudes ( positive integers ) ,

Write a function called max-ops-diff in R5RS Scheme that takes a list of magnitudes (positive integers), zero excluded. Then perform the operation of either placing a + or - in front of each number, thus making it positive or making it negative, and getting the sum of these values. Determine the maximum difference of the number of + and - required for a sum of 0. In other words, how many positive and negative values are required to produce a sum of 0 with the given magnitudes. If a sum of 0 is not possible then -1 should be returned. All values must be used.

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 Programming Questions!