We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defdayOfProgrammer(year):# Write your code herecabisat=Falseifyear<1918:# Julian Leap Year rule: Divisible by 4ifyear%4==0:cabisat=Trueelse:cabisat=Falseelse:# Gregorian Leap Year rule: Divisible by 4, except divisible by 100 unless divisible by 400cabisat=(year%4==0andyear%100!=0)or(year%400==0)totalMonth=0totalTemp=0currentDate=''foriinrange(1,13):ifi==2:ifcabisatisTrue:totalTemp+=29else:totalTemp+=28totalMonth+=1else:ifiin[1,3,5,7,8,10,12]:totalTemp+=31totalMonth+=1else:totalTemp+=30totalMonth+=1iftotalTemp>=256:# Calculate the exact day of the 256th dayday_of_programmer=256-(totalTemp-(31ifiin[1,3,5,7,8,10,12]else30))# Ensure the month is two digitstotalMonthStr=f'{i:02d}'currentDate=f'{day_of_programmer}.{totalMonthStr}.{year}'returncurrentDate
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day of the Programmer
You are viewing a single comment's thread. Return to all comments →