Advertisement
rdrewd

problem19.py

May 18th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. #! `env python` -t
  2.  
  3. def main():
  4.     """
  5.    Project Euler #19
  6.    =================
  7.    
  8.    How many months in the 20th century started on a
  9.    Sunday.
  10.    20th century is 1 Jan 1901 to 31 Dec 2000
  11.    In the Python date module, Sunday is day 6.
  12.    """
  13.     import datetime
  14.     Sunday=6
  15.     sum=0
  16.     for year in xrange(1901, 2001):
  17.         for month in xrange(1,13):
  18.             if datetime.date(year, month, 1).weekday() \
  19.                     == Sunday:
  20.                 sum+=1    
  21.     return sum
  22. # end 'main'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement