Find the first day of a given year from a base year having first day as Monday | Function to find the day of 1 st January of Y year ; Count years between years Y and B ; Count leap years ; Non leap years ; Total number of days in the years lying between the years Y and B ; Actual day ; Driver code
def findDay ( Y , B ) : NEW_LINE INDENT lyear , rest , totaldays , day = 0 , 0 , 0 , 0 ; NEW_LINE Y = ( Y - 1 ) - B ; NEW_LINE lyear = Y // 4 ; NEW_LINE rest = Y - lyear ; NEW_LINE totaldays = ( rest * 365 ) + ( lyear * 366 ) + 1 ; NEW_LINE day = ( totaldays % 7 ) ; NEW_LINE if ( day == 0 ) : NEW_LINE INDENT print ( " Monday " ) ; NEW_LINE DEDENT elif ( day == 1 ) : NEW_LINE INDENT print ( " Tuesday " ) ; NEW_LINE DEDENT elif ( day == 2 ) : NEW_LINE INDENT print ( " Wednesday " ) ; NEW_LINE DEDENT elif ( day == 3 ) : NEW_LINE INDENT print ( " Thursday " ) ; NEW_LINE DEDENT elif ( day == 4 ) : NEW_LINE INDENT print ( " Friday " ) ; NEW_LINE DEDENT elif ( day == 5 ) : NEW_LINE INDENT print ( " Saturday " ) ; NEW_LINE DEDENT elif ( day == 6 ) : NEW_LINE INDENT print ( " Sunday " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " INPUT ▁ YEAR ▁ IS ▁ WRONG ! " ) ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT Y = 2020 ; B = 1900 ; NEW_LINE findDay ( Y , B ) ; NEW_LINE DEDENT