1 Jan 2017 was a Sunday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
I was given this information in prior. I am supposed to write 1 a program to return the day (e.g. Sun, Mon, Tue, etc) in 2017, given input parameters date and month.
months = ["Jan","Feb","March", "April", "May", "June", "July", "September", "October", "November", "December"]
days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
def whatday(date,mth):
mth1 = []
day1 =[]
counter=0
for mths in months:
enqueue(mth1, mths)
for day in days:
enqueue(day1,day)
for counter in range(1, daysofthemonth(mths)+1):
if counter == date and mths==mth:
curr_day = dequeue(day1)
break
if counter == daysofthemonth(mths):
dequeue(day1)
dequeue(mth1)
counter = 0
if len(day1)==0:
for day in days:
enqueue(day1,day)
else:
dequeue(day1)
return curr_day
My code works for the first week of January but returns None onwards.