Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could you help me revise both of theseThank you very much Question 3b: Three Subset Sum (4 points) Write a function three subset sum()that determines

Could you help me revise both of theseThank you very much image text in transcribed
image text in transcribed
Question 3b: Three Subset Sum (4 points) Write a function three subset sum()that determines if there are at most three numbers in the given list that L contains no duplicate values. that sum to numbers.Assume See the test cases for examples. In (221s def three subset sun(L, n) subset-False for x in range(len(L)) for y in range(x) comparing every two numbers sum with subsetTrue break if subsetTrue: break reture subset Your code here In 1231 three subset aum(1,2,3.41,5)re Out (231 True In 124)1 three subset sum(t-2, 5, 5, 21)Te out(2411 False In 125) three subset su(1-2,,5, 2),True Out(25]: False In 126) three subset sum(t-1, 10, ,21, 8)-als Out( 261 True In HIDDEN TESTS In [ ]: 1, HIDDEN TESTS In I Ji HIDDEN TESTS Question 3a: Pair Sum (2 points) Write a function pairSum( For example: (1, n) that determines if there are any two numbers in the list 1 that add ton pairSun t1,2, 31, 5) should retum True, since 2+3-5. pairsumt, 2, 31, 6) should retum False since there are no two numbers that add to 6 pairSum(11, 2, 3, 3,6)should return True because there are two 3s in the list which sum is 6 In (51 def pairsum(1, n)s def pairsum(1, leng-len(1) for i in range(,leng) if 11+1131 tlag-1 it flagi return True elsei return Palse Your code here out[6): True In 17] pairsum((1, 2, 21, 4)rue out(7): True In 1811 pairsum([1, 2, 31, 6False Out(811 False

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

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions