mirror of
https://github.com/correl/euler.git
synced 2024-11-27 19:19:50 +00:00
Created main() function in e019, missed it in the last commit.
git-svn-id: file:///srv/svn/euler@64 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
parent
12c5dd7875
commit
672eb30f3e
1 changed files with 23 additions and 22 deletions
13
e019.py
13
e019.py
|
@ -20,12 +20,13 @@ class Day:
|
||||||
def is_leap_year(year):
|
def is_leap_year(year):
|
||||||
return (year % 100 > 0 and year % 4 == 0) or (year % 400 == 0)
|
return (year % 100 > 0 and year % 4 == 0) or (year % 400 == 0)
|
||||||
|
|
||||||
year = 1900
|
def main():
|
||||||
# 1/1/1900 was a Monday
|
year = 1900
|
||||||
first_day = Day.MONDAY
|
# 1/1/1900 was a Monday
|
||||||
|
first_day = Day.MONDAY
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
while year < 2000:
|
while year < 2000:
|
||||||
year = year + 1
|
year = year + 1
|
||||||
# Count last year's days to advance the starting weekday
|
# Count last year's days to advance the starting weekday
|
||||||
days = 366 if is_leap_year(year - 1) else 365
|
days = 366 if is_leap_year(year - 1) else 365
|
||||||
|
@ -43,7 +44,7 @@ while year < 2000:
|
||||||
if first_sunday == 1:
|
if first_sunday == 1:
|
||||||
total = total + 1
|
total = total + 1
|
||||||
|
|
||||||
print 'Total months beginning on Sunday from 1/1/1901 to 12/31/2000: {0}'.format(total)
|
print 'Total months beginning on Sunday from 1/1/1901 to 12/31/2000: {0}'.format(total)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue