Created
March 1, 2012 19:49
-
-
Save nicokruger/1952620 to your computer and use it in GitHub Desktop.
find the bug part one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import calendar | |
| import sys | |
| def ConvertDays(days): | |
| year = 1980 | |
| while days > 365: | |
| if calendar.isleap(year): | |
| if days > 366: | |
| days -= 366 | |
| year += 1 | |
| else: | |
| days -= 365 | |
| year += 1 | |
| return year | |
| if len(sys.argv) < 2: | |
| print("Specify number of days since 1980") | |
| sys.exit(1) | |
| print("Year: %i" % ConvertDays(int(sys.argv[1]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment