Question: Question 2: Subset Sum (3 points) Write a function subsetsum(), s) that determines if there are any two numbers in the list that add to

 Question 2: Subset Sum (3 points) Write a function subsetsum(), s)

Question 2: Subset Sum (3 points) Write a function subsetsum(), s) that determines if there are any two numbers in the list that add to s. e.g., for ([1, 2, 3], 5), it would be True, since 2 + 3 = 5. ([1, 2, 3), 6) would be false since there are no two numbers that add to six in the list (you cannot use the same value of three twice). On the contrary, if the input were (1, 2, 3, 3), 6), this would be true because there are two 3s in the list. In [ ]: def subsetsum (1, 3): return x NIn [ ]: print ("Are my sample test cases correct?") print("#1", subsetsum([1, 2, 3], 5) = True) print("#2", subsetsum([1, 2, 2], 5) == false) print ("#3", subsetsum ([1, 2, 3, 3), 6) == True)

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