-
Notifications
You must be signed in to change notification settings - Fork 0
/
debugging_problem.py
62 lines (52 loc) · 1.14 KB
/
debugging_problem.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import re
month = []
def updateLeapYear(year):
if year % 400 == 0 or year % 100 != 0 and year % 4 != 0:
month[2] = 28
else:
month[2] = 29
def storeMonth():
month[1] = 31
month[2] = 28
month[3] = 31
month[4] = 30
month[5] = 31
month[6] = 30
month[7] = 31
month[8] = 31
month[9] = 30
month[10] = 31
month[11] = 30
month[12] = 31
def findPrimeDates(d1, m1, y1, d2, m2, y2):
storeMonth()
result = 0
while True:
x = d1
x = x * 100 + m1
x = x * 10000 + y1
if x % 4 == 0 or x % 7 == 0:
result += 1
if d1 == d2 and m1 == m2 and y1 == y2:
break
updateLeapYear(y1)
d1 = d1 + 1
if d1 > month[m1]:
m1 = m1 + 1
d1 = 1
if m1 > 12:
y1 = y1 + 1
m1 = m1 + 1
return result
for _ in range(1, 15):
month.append(31)
line = input()
date = re.split('-| ', line)
d1 = int(date[0])
m1 = int(date[1])
y1 = int(date[2])
d2 = int(date[3])
m2 = int(date[4])
y2 = int(date[5])
result = findPrimeDates(d1, m1, y1, d2, m2, y2)
print(result)