question archive  I will require help on this Python question

 I will require help on this Python question

Subject:Computer SciencePrice: Bought3

 I will require help on this Python question.This is the background on the following problem.

Let's assume that four staff members (Analysia, Bernard, Christie, and Diana) want to teeter (i.e., sit) on these totters, and let's further assume that Analysia weighs 30kg, Bernard weighs 35kg, Christie weighs 25kg, and Diana weighs 30kg. Is it possible to arrange the staff in some way on the teeter-totter such that it would be balanced? The answer is yes: with Analysia and Diana on one side, and Bernard and Christie on the other, each side of the teeter-totter would have 60kg of weight on it.

 

Now let's imagine we add a fifth staff member: Elijah, who weighs 50kg. Can the teeter-totter be balanced now? Again, yes. With Bernard and Elijah on one side, and with Analysia, Christie, and Diana on the other, each side of the teeter-totter has 85kg of weight on it, even though the two sides don't have the same number of staff.

 

Equivalently, we can consider a list in Python "balanceable" if it is possible to permute its elements and put an imaginary fulcrum between two elements such that the sum of elements on the left side of the fulcrum is equal to the sum of the elements on the right half of the fulcrum.

For example,

a = [9, 26, 2, 19]

is balanceable, because we could rearrange the elements of a to be [9, 19, 2, 26] and place the fulcrum between a[1] and a[2] and the sum of the elements on each side of the fulcrum would be 28. (Note that other arrangements of the elements of a are possible as well.) Similarly,

b = [1, 2, 3, 9, 3]

is also balanceable, because we could, for instance, rearrange the elements of b to be [9, 3, 3, 1, 2] and place the fulcrum between b[0] and b[1], in which case the sum of the elements on each side of the fulcrum would be 9. Note that the list is balanceable even though the number of elements on each side of the fulcrum is different, with one element on the left and four elements on the right.

By contrast, note that

c = [19, 8, 12]

is not balanceable. There is no way to permute the elements of c and place a fulcrum between any two of them and have the list be balanced.

 

The question is as follows:

 

 In Python, implement a function called balanceable that accepts one parameter: a list of integers called numbers. The function should return True if numbers is balanceable and False otherwise. You may assume that len(numbers) is positive and greater than or equal to 2.

 

It'll be greatly appreciated if you can help me answer this question.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE