Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Just for fun. Without using any imports. solution in Creative category for When is Friday? by vby
def friday(day):
month={1:0, 2:3, 3:3, 4:6, 5:1, 6:4, 7:6, 8:2, 9:5, 10:0, 11:3, 12:5}
d, m, y = map(int, day.split('.'))
t=int(str(y)[-1])+10*int(str(y)[-2])
v=y-t
if v % 400 == 0:
year_shift=6
elif (v-300) % 400 ==0:
year_shift=0
elif (v-200) % 400 ==0:
year_shift=2
elif (v-100) % 400 == 0:
year_shift=4
month_shift=month[m]
day_shift=d % 7
if (y % 400 ==0) and (m==1 or m==2): #Leap year
year2_shift=int((t + (t/4)) % 7) - 1
elif (y % 100 !=0 and y % 4 ==0) and (m==1 or m==2): #Leap year
year2_shift=int((t + (t/4)) % 7) - 1
else: # Common year
year2_shift=int((t + (t/4)) % 7)
if ((year_shift+year2_shift+month_shift+day_shift) % 7)>5:
return 12-((year_shift+year2_shift+month_shift+day_shift) % 7)
else:
return 5 - ((year_shift+year2_shift+month_shift+day_shift) % 7)
Feb. 2, 2020