Please implement an “efficient” program name it p7 to solve the following problem and give big O notations of all your functions and main routine in document strings enclosed in triple quotes. Your program should read input of two lines, the first line specifies the sum of integer pairs which is looking for, and the second line contains a list of integers. Your program should read all t7*.dat in the same directory as your p7.py or p7.ipynb, and generate output for each t7*.dat as the example below. You need handle whitespace as the whitespace convention and handle errors as always.
Input Example:
$ cat t70.dat
30
1,-56,32,5,-2,25
Output Example:
32 + -2 = 30
5 + 25 = 30
1, -56
Note: the output order of the remaining integers unpaired is not strict, i.e., both 1, -56 or -56, 1 are fine for above output example.
Problem 2
Please give the big O notation for the function below. Note: please make this answer as a comment at end of problem 1 above and thus you only need to upload it on Canvas all together.
def myzip(a):
while True:
k = len(a)
for x,i in enumerate(a):
if len(i):
print(i[0])
a[x] = a[x][1:]
else:
k -= 1
if k == 0:
break
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here