Skip to content

Instantly share code, notes, and snippets.

View KendrickAng's full-sized avatar
🏠
Working from home

Kendrick KendrickAng

🏠
Working from home
View GitHub Profile
@KendrickAng
KendrickAng / coinchange.py
Created February 6, 2022 05:05
Python implementation of the polynomial-time algorithm checking optimality of the coin-change problem, by David Pearson
# referencing https://math.stackexchange.com/questions/4139845/change-making-problem-pearson-algorithm-to-check-the-optimality-of-greedy-solu
c0 = [4,3,1]
c1 = [10,7,5,4,1]
c2 = [13,11,7,5,3,2,1]
c3 = [7,6,5,4,3,2,1]
c4 = [21,17,11,10,1]
c5 = [64,32,16,8,4,2,1]
def greedy(coins, amt):
used = []