CarlosLabs
Hackerrank Challenges - Day of the programmer
(CM: use modulo math for finding the right date on a leap year)
#!/bin/python3 import math import os import random import re import sys # Complete the dayOfProgrammer function below. def dayOfProgrammer(year): dop = 0 if (year == 1918): dop = "26.09." + str(year) else: if (year < 1918): if ((year % 4)==0): dop = "12.09." + str(year) else: dop = "13.09." + str(year) else: if (((year % 4)==0) and ((year % 100)!=0)): dop = "12.09." + str(year) else: dop = "13.09." + str(year) if ((year % 400)==0): dop = "12.09." + str(year) return dop if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') year = int(input().strip()) result = dayOfProgrammer(year) fptr.write(result + '\n') fptr.close()