GH avatar Bite 175. Find missing dates

Complete get_misssing_dates that takes an (unordered) sequence of datetime.date objects. It should determine what the start and end date of this sequence is and return the missing dates.

Here is an example (horizontal scroll code below):

>>> from datetime import date
>>> from missing_dates import get_misssing_dates
>>> date_range = [date(year=2019, month=2, day=n) for n in range(1, 11, 2)]
>>> date_range
[datetime.date(2019, 2, 1), datetime.date(2019, 2, 3), datetime.date(2019, 2, 5), datetime.date(2019, 2, 7), datetime.date(2019, 2, 9)]

# our function returns the missing dates
# = the ones that were not generated in the preceding code
>>> sorted(get_misssing_dates(date_range))
[datetime.date(2019, 2, 2), datetime.date(2019, 2, 4), datetime.date(2019, 2, 6), datetime.date(2019, 2, 8)]

Some modules make this fairly easy (hint hint).

Thanks @shravankumar147 for sharing this idea on Twitter last week :)

Good luck and keep calm and code in Python!

Login and get coding
go back Intermediate level
Bitecoin 3X

59 out of 59 users completed this Bite.
Will you be Pythonista #60 to crack this Bite?
Resolution time: ~29 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 2.5 on a 1-10 difficulty scale.
» You can do it! 😌

We use Python 3.7