0
Why is this program a mistake? [6]
Can anyone point out why my code can't satisfy the last test case in "Days between Dates" challenge? https://sololearn.com/compiler-playground/cH09bjWgPqg9/?ref=app
9 Antworten
+ 1
Celvien Kurniawan Actually, yes...
+ 1
Looks like, i overlooked it. Honestly, i was taught that leap year is divisible by 4 only
+ 1
Celvien Kurniawan It's also correct, except for the century years that are not divisible by 400. 1896 and 1904 are leap years. 1600 and 2000 are leap years, but 1800 and 1900 are not leap years.
+ 1
Jan i see... Thanks for the insight. I'll try to fix it soon.
0
have you considered leap years?
0
Bob_Li yes. In the diy function, i add some calculation for leap years (i use variable 'n').
0
January 1, 1900
December 31, 1900
Output: 365
January 1, 1901
December 31, 1901
Output: 364
1900, 1800, 1700 are not leap years.
Only century years divisible by 400 are leap years.
0
Jan eh, really?!
0
I was wondering how the leapyear calculation was so simple..