This Hackerrank problem asks you given the year, the 256 date of that year according to the Russian Calendar.

The Code:

import sys
def solve(year):
months = [31,28,31,30,31,30,31,31]
if year > 1918:
if year%400 == 0 or (year%4 == 0 and year%100 != 0):
months[1] = 29
tmp = sum(months)
day = 256-tmp
else:
tmp = sum(months)
day = 256-tmp
elif year == 1918:
months[1] = 15
tmp = sum(months)
day = 256-tmp
else:
if year%4 == 0:
months[1] = 29
tmp = sum(months)
day = 256-tmp
else:
tmp = sum(months)
day = 256-tmp
return (str(day) + '.' + "09" + '.' + str(year))
year = int(input().strip())
result = solve(year)
print(result)

For this problem, I set the number of days in the months from January through August into an array and summed them together. After which I subtracted from 256 and got the day. To get the variations in days I altered the month of February based on the calendar system.

Developer Aside:

I took the easy way out in displaying the month since in the Russian calendar system (regardless of the year) the 256 day lands in September.

### Like this:

Like Loading...

*Related*