/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
!/usr/bin/python # Project Euler - Problem 19 months = [["JAN",2], ["FEB", 5],["MAR", 5],["APR",1],["MAY",3],["JUNE",6], ["JULY",1],["AUG",4],["SEPT",7],["OCT",2],["NOV",5],["DEC",7]] cnt = 0 for year in range(1901, 2001): for month in months: if month[1] % 7 == 0: cnt += 1 if month[0] != "FEB" and year+1 % 4 == 0: # Leap year month[1] += 2 elif month[0] == "FEB" and year % 4 == 0: month[1] += 2 else: month[1] += 1 print cnt