We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
To all those who are failing TC 3 and 4, there are several reasons why this could be happening:
1. Make sure both result is calculated with both dates inclusive.
Make sure you cycle through months correctly. I suspect both these cases start from a date in December, so remember to loop correctly to January (depends entirely on your method of solving the problem.)
Trim the outputs correctly (Remove redundant whitespaces).
If you use the floor() function in C++, remember to handle Double --> Int or reverse conversions properly.
If you are using Zeller's Congruence method, ensure that you avoid negative modulus.
There should be no invalid date test cases as such, but if there are, handle appropriately by avoiding the invalid date, but still checking dates in between.
Remember to swap the dates if the second date is before the first date. Read the test cases properly, and you will notice the cases when this can occur.
If you solve all these issues, all test cases should pass.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #19: Counting Sundays
You are viewing a single comment's thread. Return to all comments →
To all those who are failing TC 3 and 4, there are several reasons why this could be happening: 1. Make sure both result is calculated with both dates inclusive.
Make sure you cycle through months correctly. I suspect both these cases start from a date in December, so remember to loop correctly to January (depends entirely on your method of solving the problem.)
Trim the outputs correctly (Remove redundant whitespaces).
If you use the floor() function in C++, remember to handle Double --> Int or reverse conversions properly.
If you are using Zeller's Congruence method, ensure that you avoid negative modulus.
There should be no invalid date test cases as such, but if there are, handle appropriately by avoiding the invalid date, but still checking dates in between.
Remember to swap the dates if the second date is before the first date. Read the test cases properly, and you will notice the cases when this can occur.
If you solve all these issues, all test cases should pass.