Login and get codingComplete
get_misssing_dates
that takes an (unordered) sequence ofdatetime.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!
Will you be the 147th person to crack this Bite?
Resolution time: ~36 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌