year = int(input("Enter the year: "))
month = int(input("Enter the month: "))
day = int(input("Enter the day: "))
# need to raise valueerror if year < 1
def anchor(year) :
rem = (year//100)%4
if rem == 0:
return 2
elif rem == 1:
return 0
elif rem == 2:
return 5
elif rem == 3:
return 3
def calc_leap(year) :
if year / 4 != year // 4 :
return 0
elif year / 100 != year // 100 :
return 1
elif year / 400 != year // 400 :
return 0
else :
return 1
leap = calc_leap(year)
def calc_doomsday(year) :
yy = year - 100 * (year // 100)
return (anchor(year) + yy // 12 + yy % 12 + (yy % 12) // 4) % 7
doom = calc_doomsday(year)
def calc_weekday(year, month, day) :
# calculate forward/backward from nearest doomsday
if month == 1:
return (day - 3 - leap + doom) % 7
elif month == 2:
return (day - 28 - leap + doom) % 7
elif month == 3:
return (day - 0 + doom) % 7
elif month == 4:
return (day - 4 + doom) % 7
elif month == 5:
return (day - 9 + doom) % 7
elif month == 6:
return (day - 6 + doom) % 7
elif month == 7:
return (day - 11 + doom) % 7
elif month == 8:
return (day - 8 + doom) % 7
elif month == 9:
return (day - 5 + doom) % 7
elif month == 10:
return (day - 10 + doom) % 7
elif month == 11:
return (day - 7 + doom) % 7
elif month == 12:
return (day - 12 + doom) % 7
def print_weekday(x) :
if x == 0:
print("Sunday")
elif x == 1:
print("Monday")
elif x == 2:
print("Tuesday")
elif x == 3:
print("Wednesday")
elif x == 4:
print("Thursday")
elif x == 5:
print("Friday")
elif x == 6:
print("Saturday")
print_weekday(calc_weekday(year, month, day))
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}