Swap '2016' for '1996' to stop faulty logic from passing unit test in Leap#979
Swap '2016' for '1996' to stop faulty logic from passing unit test in Leap#979cmccandless merged 2 commits intoexercism:masterfrom
Conversation
[This leap solution](http://exercism.io/submissions/7ef5b0ab93b540f79cdee9f153e0a21c) should not pass the unit test, since it checks whether `year % 100` and `year % 400` are equal in order to tell whether the year it has been passed is a leap year. This works for 2016 because `2016 % 100` and `2016 % 400` both evaluate to 16. 1996, another leap year that is divisible by 4 but not 100, does not have this property and, under that solution, would falsely not be classed as a leap year.
|
@cruxicheiros Thanks for the pull request! Good catch; turns out this issue was already addressed recently by updating the canonical data, but this track had not been updated yet. If you can modify your changes to conform to the new version of the canonical data, we should be good to go! |
|
@cmccandless This is actually a different corner case. The one the canonical data has been updated to fix is one where it's possible to pass all the tests by checking if the year is evenly divisible by 16. With this one, it's possible to pass all the unit tests by checking if Coincidentally, 16 is also not a factor of 1996, so changing the value in the canonical data from 2020 to 1996 would address both issues. Edit: I have submitted a PR to the problem-specifications repo. |
|
@cruxicheiros Yes, submitting a PR to problem-specifications was the correct action. Thanks! 😄 Now that that PR has been merged, please update the rest of |
|
@cmccandless Updated the version number. I think that's it done. |
|
@cruxicheiros Merged! Congrats and thanks for working on this! |
This Leap solution should not pass the unit test, since it checks whether
year % 100andyear % 400are equal in order to tell whether the year it has been passed is a leap year. This works for 2016 because2016 % 100and2016 % 400both evaluate to 16.1996, another leap year that is divisible by 4 but not 100, does not have this property and, under that solution, would be falsely not classed as a leap year.