+ 3
Day of Week Revisited - Wrong Outputs?
I recently found out that the following program returns incorrect outputs for dates with years > 2100 ... Eg - When I gave input - 01 01 2150, it returned Friday, when it was thursday... Can anyone help me where does it go wrong? https://code.sololearn.com/c6fI7d6YO5rQ/?ref=app Thanks to this error, I lost a challenge in CodeChef... Please help!
4 odpowiedzi
+ 3
Did you see the code posted by @David?
Would this method work for you?
https://www.sololearn.com/discuss/411673/?ref=app
+ 2
@jay
Yes, I think ill have to switch to that...
+ 2
@jay
But what about my algorithm, why isn't that working?
+ 2
@JPM7
Sir, the formula for date to day you have used is entirely different from what I tried to implement...
You have used a formula, I tried counting days literally to get the date...
Perhaps this is the reason my hit and trial formula doesn't prove to be successful - I simply did not complete my research on this...
Just read about odd-day calculation back then and tried implementing, and by chance it worked for years less than 2100...
Ill retry with a better approach like this one...
Thank You, Sir!