Previously, I described how to calculate the checkdigit of the NUS matriculation number. Unfortunately, the numbering scheme for the matriculation number has changed since the turn of the decade, which means the old calculation method no longer applies.

I have studied the new matriculation numbers (which are prefixed with A) and have managed to reverse engineer the new checkdigit scheme.

Assume the numerical digits of the
matriculation number are C1,C2,C3,C4,C5, C6. Take the sum of the digits C1 to C6, and find the modulus (remainder) of this sum when divided by 13.

Compare the remainder with the following table to obtain the checkdigit.

Y | X | W | U | R | N | M | L | J | H | E | A | B |

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Reverse-engineering the checkdigit scheme was easier this time round, for two reasons. First, the ordering of the checkdigits followed that of the earlier scheme, albeit reversed. Second, and more importantly, the checkdigit scheme was of a lower complexity, being a simple sum of the component digits. This I found puzzling, because it actually fails to preserve an important property that was present in the previous scheme.

A checkdigit serves only one purpose: it is a quick way to determine if a given registration number is correctly entered. Taking the remainder of a sum of the component digits allows us to detect if one digit has been wrongly typed; if one digit is mistyped, the checkdigit would be different. Also, if several digits have been mistyped, the error is still detectable, though there is a small chance that the sum of errors just happens to be a multiple of 13 and hence undetectable.

The weakness of taking the modulus of the sum is that it does not allow transposed digits to be detected. For example, if any or all the digits in a registration number were scrambled around, this would be undetectable as the sum of digits would remain the same. A more robust checkdigit scheme accounts for this by weighting each digit position with a different weight, thus allowing for most digit transpositions to be detected.

Transpositions are fairly common when typing strings of numbers, so it is fairly unacceptable for the checkdigit scheme to fail to account for this.

The weakness of taking the modulus of the sum is that it does not allow transposed digits to be detected. For example, if any or all the digits in a registration number were scrambled around, this would be undetectable as the sum of digits would remain the same. A more robust checkdigit scheme accounts for this by weighting each digit position with a different weight, thus allowing for most digit transpositions to be detected.

Transpositions are fairly common when typing strings of numbers, so it is fairly unacceptable for the checkdigit scheme to fail to account for this.

## 1 comment:

Damn awesome post here! Rushing to submit an assignment and this helped me quickly calculate my teammate's last letter :p

Post a Comment