Skip to content

Instantly share code, notes, and snippets.

@BharathKumarS
Last active February 27, 2020 22:00
Show Gist options
  • Save BharathKumarS/583dd6abc6283758d053d2466efa78b3 to your computer and use it in GitHub Desktop.
Save BharathKumarS/583dd6abc6283758d053d2466efa78b3 to your computer and use it in GitHub Desktop.
HackerRank, print a string representing the date of the 256th day of the year given.
# Day of the coder from HackerRank
def russia(year):
days = 256
sams = 0
months = [31,28,31,30,31,30,31,31,30]
if 1700 <= year <= 1917:
months[8] = months[8] - 13
if (year % 4) == 0:
months[1] = months[1] + 1
elif year == 1918:
months[1] = months[1] - 13
elif 1919 <= year <= 2700:
if (year % 400) == 0 or (year % 4) == 0 and (year % 100) != 0:
months[1] = months[1] + 1
for month in months:
if days > month:
sams = sams + 1
days = days - month
if days > 0:
sams += 1
return(str(days).zfill(2) + '.' + str(sams).zfill(2) + '.' + str(year))
if __name__ == '__main__':
year = 1737
print(russia(year))
@BharathKumarS
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment