In the given example,
D = Monday. As the 1st of the day of the month is a Monday, it means the 7th and 14th of the month will be Sundays (A week has 7 days). So the 16th day (N = 16) of the month will be a Tuesday.
determine day of the week of the given date and month
weekNames = ['Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
D = input()
N = int(input())
i = N%7 -1
if D in weekNames:
dayIndex = weekNames.index(D)+i
if dayIndex >= 7:
dayIndex -= 7
print(weekNames[dayIndex])
Comments
Leave a comment