Today is my day 57th of #100dayofcode and #python. Today also continued to learned more properties of SQL including INNER JOIN,LEFT JOIN, RIGHT JOIN, FULL JOIN, IS LIKE, NOT LIKE, IS NULL, IS NOT NULL etc from Datacamp
Also tried to complete some assignment in coursera regarding to the topic algorithmic toolbox. I tired to solve money change problems, Fractional Knapsack problems, car fueling problem.
Python code
We are going to change Rs.28. In the shop shopkeeper has only Rs.1, Rs.5, Rs.10 as a change. So, possible change for 28 are 10,10,5,1,1,1. For this I tried to write following code.
number = 28
valid_changes = [1, 5, 10]
rem = number
changes=[]
while rem!=0:
# print(rem)
if rem%valid_changes[2]==0:
changes.extend([valid_changes[2]])
rem -= valid_changes[2]
elif rem%valid_changes[1]==0:
changes.extend([valid_changes[1]])
rem -= valid_changes[1]
else:
changes.extend([1])
rem-=1
print(len(changes))
When above code is run we get,
28
27
26
25
20
10
[1, 1, 1, 5, 10, 10]
Day 57 Of #100DaysOfCode
— Durga Pokharel (@mathdurga) February 23, 2021
* More properties of SQL(LEFT JOIN, RIGHT JOIN, FULL JOIN, INNER JOIN)
* More About Algorithm
* Code For Money Change#WomenWhoCode #teachertwitter #DEVCommunity pic.twitter.com/1zuUa1nQ6M
Top comments (0)