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

1st Nov 2024, 6:24 AM
Celvien Kurniawan
Celvien Kurniawan - avatar
9 Respuestas
+ 1
Celvien Kurniawan Actually, yes...
1st Nov 2024, 7:49 AM
Jan
Jan - avatar
+ 1
Looks like, i overlooked it. Honestly, i was taught that leap year is divisible by 4 only
1st Nov 2024, 8:12 AM
Celvien Kurniawan
Celvien Kurniawan - avatar
+ 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.
1st Nov 2024, 8:42 AM
Jan
Jan - avatar
+ 1
Jan i see... Thanks for the insight. I'll try to fix it soon.
1st Nov 2024, 8:57 AM
Celvien Kurniawan
Celvien Kurniawan - avatar
0
have you considered leap years?
1st Nov 2024, 6:38 AM
Bob_Li
Bob_Li - avatar
0
Bob_Li yes. In the diy function, i add some calculation for leap years (i use variable 'n').
1st Nov 2024, 6:43 AM
Celvien Kurniawan
Celvien Kurniawan - avatar
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.
1st Nov 2024, 7:30 AM
Jan
Jan - avatar
0
Jan eh, really?!
1st Nov 2024, 7:38 AM
Celvien Kurniawan
Celvien Kurniawan - avatar
0
I was wondering how the leapyear calculation was so simple..
1st Nov 2024, 7:49 AM
Bob_Li
Bob_Li - avatar