• + 0 comments
    def dayOfProgrammer(year):
        # Write your code here
        cabisat = False
        if year < 1918:
            # Julian Leap Year rule: Divisible by 4
            if year % 4 == 0:
                cabisat = True
            else:
                cabisat = False
        else:
            # Gregorian Leap Year rule: Divisible by 4, except divisible by 100 unless divisible by 400
            cabisat = (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
        totalMonth = 0
        totalTemp= 0
        currentDate =''
        for i in range(1, 13):
            if i == 2:
                if cabisat is True:
                    totalTemp+=29
                else:
                    totalTemp +=28
                totalMonth+=1
            else:
                if i in [1, 3, 5, 7, 8, 10, 12]:
                    totalTemp+=31
                    totalMonth+=1
                else:
                    totalTemp+=30
                    totalMonth+=1                
            if totalTemp >= 256:
                # Calculate the exact day of the 256th day
                day_of_programmer = 256 - (totalTemp - (31 if i in [1, 3, 5, 7, 8, 10, 12] else 30))
                
                # Ensure the month is two digits
                totalMonthStr = f'{i:02d}'
                currentDate = f'{day_of_programmer}.{totalMonthStr}.{year}'
                return currentDate