Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pricesPack = [[3.5, 375, 1], [2.5, 300, 2], [2, 100, 3], [3, 225, 4], [1, 50, 5],
- [1.75, 125, 6], [0.75, 75, 7], [3, 275, 8], [2.5, 150, 9], [2.25, 50, 10]]
- maxWeight = int(input("Maximalgewicht [kg]: "))
- def createRatioList(listOriginal):
- priceListRatio = []
- for x in range(0, len(listOriginal), 1):
- priceListRatio.append((listOriginal[x][1]/listOriginal[x][0]))
- priceListRatio.sort(reverse = True)
- return priceListRatio
- def createFinalList(listSorted, listOriginal):
- priceListFinal = []
- pricePackFinal = []
- currentWeight = 0
- for x in range(0, len(listSorted), 1):
- for y in range(0, len(listSorted), 1):
- if listSorted[x] == (listOriginal[y][1]/listOriginal[y][0]):
- priceListFinal.append(listOriginal[y])
- for x in range(0, len(priceListFinal), 1):
- if (currentWeight + priceListFinal[x][0]) <= maxWeight:
- currentWeight += priceListFinal[x][0]
- pricePackFinal.append(priceListFinal[x][2])
- return pricePackFinal, currentWeight
- print(createFinalList(createRatioList(pricesPack), pricesPack))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement