A simple hackerrank problem where we are charging the individual for fine on book return with various amount of fine based on return date. We are passing return date, month and year and due date, month and year to the function. First we will check if the book was return on or before the due date for that we will check whether the due and return date happened in the same month and year, if it satisfies this condition check we will first check with an if-statement that the return date is later then the due if that is so we will find the difference in dates and multiple with 15 hackos and return the fine and if the return date was before the due date or on same as due date we will not penalize the individual. After this we will check for the month in the same year, if return month is greater than the due month we will take the difference and multiply it with 500 hackos and return the fine value.
def libraryFine(d1, m1, y1, d2, m2, y2):
if (m1-m2)==0 and (y1-y2)==0:
elif (m1-m2)!=0 and (y1-y2)==0:
Now we will check if the book was not returned in due year, again if the book was return before the due year then we will not penalize the individual i.e return 0,if not we will take the difference between the years and multiply it with 10,000.
“Keep your eye on the goal, keep moving toward your target.”
In simple words the quotes says keep moving and keep hustling….(cheers:-PN)