Adapted from some code by Brendan Morley.
Excerpt from "CODE OF PRACTICE FOR THE DEFINED INTERSTATE RAIL NETWORK"
2.4.1 A check letter should be included in all vehicle identification (class and number) groups as a suffix to the vehicle number. Use of the check letter is a security measure designed to help detect errors and inadvertent or unauthorised changes in the alphanumeric coding.
2.4.2 The check letter should be determined in accordance with the following procedure:
(a) Alpha characters are allocated a numerical value according to their position in the alphabet, viz A = 1, B = 2, C = 3, -----. Y = 25, Z = 26.
(b) Leading zeros are inserted if necessary between the alpha group and the number to form a 9 character vehicle classification.
(c) Assign numerical values to each character to form a sequence a1, a2, a3, a4, N1, N2, N3, N4 and N5, where a1 to a4 correspond to the vehicle class and N1 to N5 refer to the vehicle number.
(d) Calculate the value of the following series: (1 * a1) + (2 * a2) + (3 * a3) + (4 * a4) + (5 * N1) + (6 * N2) + (7 * N3) + (8 * N4) + (9 * N5)
(e) Divide the sum by 23 and add one (1) to the remainder to give the position of the check letter in the alphabet. A check letter character of I is to be recorded as X, and O is recorded as Y.