# HackerRank ‘Library Fine’ Solution

##### Short Problem Definition:

The Head Librarian at a library wants you to make a program that calculates the fine for returning the book after the return date. You are given the actual and the expected return dates

Library Fine

##### Complexity:

time complexity is O(?)

space complexity is O(?)

##### Execution:

HackerRank does not support the dateutil library. This should have been computed in terms of date differences and not using if/else branches. Here I use the date library for convenience and readability.

##### Solution:
```#!/usr/bin/py
from datetime import date

def calculateHackos(actual, expected):
actual_date = date(actual, actual, actual)
expected_date = date(expected, expected, expected)

if actual_date.year > expected_date.year: return 10000
if actual_date.year < expected_date.year: return 0
if actual_date.month > expected_date.month: return (actual_date.month - expected_date.month) * 500
if actual_date.month < expected_date.month: return 0
if actual_date.day > expected_date.day: return (actual_date.day - expected_date.day) * 15
return 0

if __name__ == '__main__':
actual = map(int, raw_input().split())
expected = map(int, raw_input().split())
print calculateHackos(actual, expected)

```

If you enjoyed this post, then make sure you subscribe to my Newsletter and/or Feed.