-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler19.py
38 lines (33 loc) · 837 Bytes
/
euler19.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! Python2
def leapYear(year):
if year % 4 == 0:
if (year % 100)==0 and (year % 400)==0:
return 1
elif (year % 100)!=0:
return 1
else:
return 0
else:
return 0
months=[0,31,28,31,30,31,30,31,31,30,31,30,31]
currentDate=5
currentMonth=1
currentYear=1901
count=0
while 1:
currentDate+=7 #date increment
mCount=months[currentMonth]
#special leap year february month check
if currentMonth==2 and leapYear(currentYear):
mCount+=1
if currentDate > mCount: #month increment
currentMonth+=1
currentDate=currentDate - mCount
if currentMonth > 12: # year increment
currentYear+=1
currentMonth=1
if currentYear == 2001:
break
if currentDate == 1:
count+=1
print count