In this HackerEarth Sherlock and Date problem solution Watson gives a date to Sherlock and asks him what is the date on the previous day. Help Sherlock. You are given a date in DD MM YYYY format. DD is an integer without leading zeroes. MM is one of the "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November" and "December" (all quotes for clarity). YYYY is also an integer between 1600 and 2000 without leading zeroes. You have to print the date of the previous day in the same format.

HackerEarth Sherlock and Date problem solution

HackerEarth Sherlock and Date problem solution.

import datetime
from datetime import date, timedelta

n = int(raw_input())

while n>0 :
    date = raw_input();
    day , month ,year = date.split();
    assert(int(day)>0 & int(day)<31)
    #print(day+" "+month+" "+year)
    map = {

    mlist = [

    mydate = (,map[month],int(day)))  #year, month, day
    #mydate =mydate+datetime.timedelta(years=40)
    mydate= mydate-datetime.timedelta(days=1)
    mydate = mydate.isoformat();
    year ,month,day = mydate.split('-')
    #print(year+" "+month+" "+day)
    #year = mydate.strftime("%Y");
        month = month.strip("0");
    #day = mydate.strftime("%d");
       day = day.strip("0")
    print(day+" "+mlist[int(month)-1] +" "+year)