Back to Problem Solutions forum
For some reason I've got an error in this test case:
Was: 1097696166985934
Expected: 1907696166985934
But hash sum of both numbers is 80.
So my answer was obviously 1097696166985934
How should I detect swap error in such test cases?
In my opinion this test case shows how inapplicable Luhn Algorithm for error's detection.
While writting this topic I've found the confrmation of my words in this article Luhn Algorithm
I guess you should rework your test cases.
I have run into the same problem but am ignoring it for now
This point gets brought up every now and then.
The problem does mention that:
each of the numbers contain one of two errors
So submitting the original number as the answer is clearly incorrect.
It is true that Lunh's checksum is the same after the 0-9 swap; but this does mean that in this case the correct answer is the original number with the leftmost 0-9 pair swapped.
Given that 1000+ people solved this problem correctly, I don't think there is a dire necessity to rewrite the setter (I presume, to avoid the 0-9 swap issue).