Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could you use python3 to revise it Write a function pairSum(1, n) that determines if there are any two numbers in the list 1 that

Could you use python3 to revise it
image text in transcribed
image text in transcribed
Write a function pairSum(1, n) that determines if there are any two numbers in the list 1 that add to n For example: pairSumet1, 2, 31, 5) should return True , since 2+3-5 pairSume, 2. 31. 6) should return Palse since there are no two numbers that add to 6. pairsum(t1, 2, 3, 31. 6),should return True because there are two 3s in the list which sum is 6 In 1: def pairSun(1, n) length-1en (1) for i in range (0,length): for i in range(length): if i-j return True else return Palse # Your code here In 1.11 pairSum(ti, 2. 21. 4) True Write a function three subset sun(L, s) that determines if that L contains no duplicate values there are at most three numbers in the given list I, that sum to number s. Assume See the test cases for examples. In (22]: def three subset sum(L, n): subset False for x in range(len(L)) for y in range(x)1 comparing every two numbers sum with s subset True break if subset True: break return subset your code here In 123]: three subset sum(11,2,3,41. 5)True out(23)1 True In [24]three-subset-aum(t-2, out (2414 False 5, 5, 2], 8) "" True In 12511 three subset sum ( 1-2. 8,5,21. 8)rue Out 1251 False In 1 10, 5, 2). False [26]. three-subset-sun( Out[26]: 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

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

=+ What scenarios could draw the audience in?

Answered: 1 week ago

Question

=+ What graphics could stop the viewer?

Answered: 1 week ago