Given a date, return the corresponding day of the week for that date.
The input is given as three integers representing the day, month and year respectively.
Return the answer as one of the following values {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}.
 
Example 1:
Input: day = 31, month = 8, year = 2019
Output: "Saturday"

Example 2:
Input: day = 18, month = 7, year = 1999
Output: "Sunday"

Example 3:
Input: day = 15, month = 8, year = 1993
Output: "Sunday"

 
Constraints:

The given dates are valid dates between the years 1971 and 2100.

Difficulty: introductory

Starter code:

class Solution:
    def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
        

Solutions:
class Solution:
    def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
        diff_year = (year - 1971) % 7 + int((year - 1968)/4)
        print(('year:', (year - 1971), ':', (year - 1971)%7))
        print(('num leaps:', int((year - 1968)/4)))
        print(('diff_year:', diff_year))
        months = {1:0, 2:3,3:3,4:6,5:1,6:4,7:6,8:2,9:5,10:0,11:3,12:5}
        print(('month add:', months[month]))
        if year == 2100:
            leap = -1
        elif month <=2 and (year - 1968)%4 == 0:
            leap = -1
        else:
            leap = 0
        weekdate = (diff_year + months[month] + day + leap -1)%7
        print(('day:', day))
        print(weekdate)
        weekdays = {5:'Wednesday', 6:'Thursday', 7:'Friday',0:'Friday', 
                    1:'Saturday', 2:'Sunday', 3: 'Monday', 4:'Tuesday'}
        return weekdays[weekdate]
        


import calendar, datetime
class Solution:
    def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
        return calendar.day_name[datetime.date(year, month, day).weekday()]


from datetime import datetime
class Solution:
    def dayOfTheWeek(self, day: int, month: int, year: int) -> str:

        # index mapping: 0          1           2           3           4           5       6        
        weekday_name= ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
        
        # datetime is a class, whose constructor can output corresponding date-time object
        #
        # for example:
        # datetime(2020, 1, 15) = '2020-01-15 00:00:00'

        # And its strftime('%w') can convert a date-time object into a index string of weekday, start from Sunday as 0
        #
        # for example:
        # datetime(2020, 1, 15).strftime('%w') = '3'

        # Finally, use int( ... ) to carry out explicit type conversion fron str to integer as weekday index
        return weekday_name[ int( datetime(year, month, day).strftime('%w') ) ]

import datetime
import calendar

class Solution:
    
    def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
        return datetime.datetime(year, month, day).strftime('%A')