-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure out how to calculate a check digit #46
Comments
It looks to me like is done as follows:
I have not tested this. |
So, for example, 0431899. 0 + 3 + 8 + 9 = 20. 4 * 2 = 8 20 + 8 + 2 + 9 = 39 100 - 39 = 61 The checksum is 1. ...but the checksum is 4. So, that didn't work. |
Got this working in Ruby: |
Oh, wonderful. I'll compare notes and see where my logic is wrong. :) Thank you! |
OK, take two, with the addition of a new second step:
So, for example, 0431899. 0943189 0 + 4 + 1 + 9 = 14 9 * 2 = 18 = 1 + 8 = 9 14 + 9 + 6 + 7 = 36 100 - 36 = 64 The checksum is 4. Great, so that worked. Let's try with another one: F004214 8004214 8400421 8 + 0 + 4 + 1 = 13 4 * 2 = 8 13 + 8 + 0 + 4 = 25 100 - 25 = 75 The checksum is 5. Bingo. |
The SCC sometimes provides a 7-digit ID, sometimes an 8-digit ID. It turns out that the eighth digit is a checksum. This is the SCC's code to calculate that checksum but, unfortunately, it's written in Natural. So we've got to figure out Natural sufficiently to recreate the code in Python.
The text was updated successfully, but these errors were encountered: