Money change/minimum coin algorithm
I ran a few examples through the code and I have made the following assumptions:


the code calculates the minimum amount of coins needed to produce the user's input
the user can enter in a custom coin and it will use that as part of its calculations


Instead of using a matrix, I just found the highest coin which can be used to make change, then subtracted it from the total user inputted amount, and repeated it until there was no change left.

coins = [50000, 20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1]

coinToAdd = int(input("Enter in coin to add to coins:"))
userMoney = int(input("Enter in coin to calculate change:"))
coins.append(coinToAdd)
coins.sort(reverse=True)
totalCoins = 0
while [j for j in coins if userMoney &gt;= j]:
  userMoney = userMoney - [j for j in coins if userMoney &gt;= j][0]
  totalCoins = totalCoins + 1

print(totalCoins)