Skip to content

Instantly share code, notes, and snippets.

@josereyesjrz
Created March 25, 2017 21:16
Show Gist options
  • Save josereyesjrz/46d5eb6882ac6237a5f8bc7b7919da77 to your computer and use it in GitHub Desktop.
Save josereyesjrz/46d5eb6882ac6237a5f8bc7b7919da77 to your computer and use it in GitHub Desktop.
def ksack(M1, s):
sack = []
i = len(M1)-1
j = len(M1[0])-1
while (j != 0 and i >= 0):
if (j != M1[i][j][1] and j >= s[i]):
sack.append(i)
j = M1[i][j][1]
i -= 1
else:
i -= 1
return sack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment