I don't know why these codes makes error message.
Please help me
Please help me
def dynamic_sort(C):
C.sort(key = lambda x: x[1])
n = len(C)
cache = []
for y in range(0, n):
cache.append(C[y][2])
return cache
def dynamic_job(C):
cache = dynamic_sort(C)
n = len(C)
for i in range(1, n+1):
for k in range(0, i):
if C[k][1] <= C[i][0]: #this line makes the error message(IndexError: list index out of range)
if cache[k] + C[i][2] > cache[i]:
cache[i] = cache[k] + C[i][2]
max = 0
for i in range (0, n+1):
if max < cache[i]:
max = cache[i]
return max
C = [[2,5,6], [4,6,5], [6,7,4], [1,3,5], [5,8,11], [7,9,2]]
print(dynamic_job(C))
buran write Dec-05-2020, 10:01 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
