 # [Community Puzzle] How time flies

Hey, here is my ugly python code:
I’m passing all the first tests, but it seems like i have hardcoded something ?

I tried something about the 29.02.2016 => 28.02.2017.
I know there is a better way to write, but i’m beginning with python Could someone give me a hint on what’s wrong ?

``````import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

begin = input().split('.')
end = input().split('.')
def bissextile(year):
if (not year%4 and year%100) or not year%400:
return True
return False
m31=[1,3,5,7,8,10,12]
m30=[4,6,9,11]

d1 = int(begin)
d2 = int(end)
m1 = int(begin)
m2 = int(end)
y1 = int(begin)
y2 = int(end)
d=0
m=0
y=0
if d1==29 and m1==2 and d2==28 and m2==2:
d1=28
y1+=1
m=+11
d+=365
i=0
if m1 in m31:
i=31
elif m1 in m30:
i=30
else:
if bissextile(y1):
i=29
else:
i=28
while(d1!= d2):
d1+=1
d+=1
if d1 > i:
d1%=i
m1+=1
if m1>12:
m1%=12
y1+=1
while(m1!=m2):
j=0
if m1 in m31:
j=31
elif m1 in m30:
j=30
else:
if bissextile(y1):
j=29
else:
j=28
m1+=1
m+=1
d+=j
if m1==13:
m1%=12
y1+=1
while(y1!=y2):
if bissextile(y1):
d+=366
else:
d+=365
y1+=1
y+=1

if y>1:
print(f'{y} years, ', end='')
elif y==1:
print(f'{y} year, ', end='')
if m>1:
print(f'{m} months, ', end='')
elif m==1:
print(f'{m} month, ', end='')
print(f'total {d} days')``````

Try this testcase:

``````01.04.2000
01.04.2001``````
``````01.04.2000
01.04.2001
1 year, total 366 days
``````

ah. Right
Thx

I can’t pass the 06-Complex validator, and I don’t know why…
Any clues or other test ?

Try:

``````11.05.2000
04.02.2016
``````

``15 years, 8 months, total 5747 days``
1 Like

Thanks, I manage to get 100% with this one Hi guys, I fail the 3rd and 8th validator and I have no idea why… Maybe you are handling leap years incorrectly?
Validator 8 is similar to this:

``````19.03.2024
19.03.2025
``````

`1 year, total 365 days`
I handled it wrong, but got it now. Thanks a lot! 