views:

86

answers:

1

Hello,

I'm implementing the Verhoeff algorithm for a check digit scheme, but there seems to be some disagreement in web sources as to which permutation cycle should form the basis of the permutation table.

Wikipedia uses: (36)(01589427)

while apparently, Numerical Recipies uses a different cycle and this book uses: (0)(14)(23)(56789), quoted from a 1990 article by Winters. It also notes that Verhoeff used the one Wikipedia quotes.

Now, my number theory is a little rusty, but the Wikipedia cycle clearly will repeat after the 8th power, while the book one will take 10, despite it saying that s^8=s. Table 2.14(b) has other errors in the 2-cycles, so this is dubious anyway.

Unfortunately, I don't have copies of the original articles (and am too tight to pay/disgusted that 40-year old knowledge is still being held to ransom by publishers), nor a copy of Numerical Recipes to check (and am loath to install their paranoia-induced copy protection plug-in to view online).

So does any one know which is correct? Are they both correct?

+1  A: 

There's an old edition of Numerical Recipes available here as PDFs. Verhoeff algorithm is described in section 20.3. It uses the same permutation as the Wikipedia article.

interjay
Thanks interjay, but as far as I can tell, the permutation table used there is completely incorrect. The identity permutation is not there, and the other entries aren't even permutations (elements appear multiple times).
James
@James: It's exactly the same permutation as Wikipedia's, except it's arranged by columns instead of rows. If you look at the columns of Wikipedia's permutation table, you'll have the exact values as NR uses. NR formatted the table confusingly since they separated the numbers into groups of 10 when they should have been separated into groups of 8.
interjay
@interjay: Ah, I see it now. It didn't help that they also switched the orientation between the different matrices either...
James