Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions