Day of Week Revisited - Wrong Outputs? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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!

24th May 2017, 3:18 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
4 Answers
+ 3
Did you see the code posted by @David? Would this method work for you? https://www.sololearn.com/discuss/411673/?ref=app
24th May 2017, 3:27 AM
jay
jay - avatar
+ 2
@jay Yes, I think ill have to switch to that...
24th May 2017, 3:30 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
@jay But what about my algorithm, why isn't that working?
24th May 2017, 3:30 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 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!
24th May 2017, 1:15 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar