Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Zeller's congruence solution in 3rd party category for When is Friday? by charlotte0
import numpy as np
def friday(day):
#replace this for solution
#Zeller's congruence
dd = int(day[0:2])
mm = int(day[3:5])
yy = int(day[6:])
if mm == 1 or mm == 2:
mm += 12
yy -= 1
Y = yy % 100
C = np.floor(yy/100)
G = 5*C + np.floor(C/4)
#print(Y,C,G)
#print(dd,mm,yy)
return (6-(dd+np.floor(13*(mm+1)/5)+Y+np.floor(Y/4)+G))%7
if __name__ == '__main__':
print("Example:")
print(friday('23.04.2018'))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert friday('23.04.2018') == 4
assert friday('01.01.1999') == 0
print("Coding complete? Click 'Check' to earn cool rewards!")
April 29, 2020
Comments: