Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Equal Sums of Subsets Given an array of unique positive integers, divide the array into two subsets such that the absolute difference between the respective
Equal Sums of Subsets Given an array of unique positive integers, divide the array into two subsets such that the absolute difference between the respective sums of the subsets is as small as possible. For example, given [5, 10, 15, 20, 25], return the lists [10, 25] and [5, 15, 20], which has a difference of 5, which is the smallest possible difference. Here is your function signature: get_min_split(seq) where seq is a Python list or 1-dimensional Numpy array. If there are multiple possible outputs, return all of them. For example, given [5, 10, 15, 20, 25], here is the output of all valid solutions, [([15, 25], [5, 10, 20]), ([15, 20], [5, 10, 25]), ([10, 25], [5, 15, 20])] Hint: Use itertools or recursion. Also, Numpy. Please put your Python code in a Python script file and upload it. Please retain your submitted source files! Remember to use all the best practices we discussed in class. You can use any module in the Python standard library, but third-party modules (e.g., Numpy, Pandas) are restricted to those explicitly mentioned in the problem description. Equal Sums of Subsets Given an array of unique positive integers, divide the array into two subsets such that the absolute difference between the respective sums of the subsets is as small as possible. For example, given [5, 10, 15, 20, 25], return the lists [10, 25] and [5, 15, 20], which has a difference of 5, which is the smallest possible difference. Here is your function signature: get_min_split(seq) where seq is a Python list or 1-dimensional Numpy array. If there are multiple possible outputs, return all of them. For example, given [5, 10, 15, 20, 25], here is the output of all valid solutions, [([15, 25], [5, 10, 20]), ([15, 20], [5, 10, 25]), ([10, 25], [5, 15, 20])] Hint: Use itertools or recursion. Also, Numpy. Please put your Python code in a Python script file and upload it. Please retain your submitted source files! Remember to use all the best practices we discussed in class. You can use any module in the Python standard library, but third-party modules (e.g., Numpy, Pandas) are restricted to those explicitly mentioned in the problem description
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started