Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/Verhoeff-algorithm/J/verhoeff-algorithm-1.j
Normal file
30
Task/Verhoeff-algorithm/J/verhoeff-algorithm-1.j
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
cyc=: | +/~@i. NB. cyclic group, order y
|
||||
ac=: |(+-/~@i.) NB. anticyclic group, order y
|
||||
a2n=: (+#)@ NB. add 2^n
|
||||
di=: (cyc,.cyc a2n),((ac a2n),.ac)
|
||||
|
||||
D=: di 5
|
||||
INV=: ,I.0=D
|
||||
P=: {&(C.1 5 8 9 4 2 7 0;3 6)^:(i.8) i.10
|
||||
|
||||
verhoeff=: {{
|
||||
c=. 0
|
||||
for_N. |.10 #.inv y do.
|
||||
c=. D{~<c,P{~<(8|N_index),N
|
||||
end.
|
||||
}}
|
||||
|
||||
traceverhoeff=: {{
|
||||
r=. EMPTY
|
||||
c=. 0
|
||||
for_N. |.10 #.inv y do.
|
||||
c0=. c
|
||||
c=. D{~<c,p=.P{~<(j=.8|N_index),N
|
||||
r=. r, c,p,j,N_index,N,c0
|
||||
end.
|
||||
labels=. cut 'cᵢ p[i,nᵢ] i nᵢ n cₒ'
|
||||
1 1}.}:~.":labels,(<;._1"1~[:*/' '=])' ',.":r
|
||||
}}
|
||||
|
||||
checkdigit=: INV {~ verhoeff@*&10
|
||||
valid=: 0 = verhoeff
|
||||
30
Task/Verhoeff-algorithm/J/verhoeff-algorithm-2.j
Normal file
30
Task/Verhoeff-algorithm/J/verhoeff-algorithm-2.j
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
checkdigit 236 12345 123456789012
|
||||
3 1 0
|
||||
valid 2363
|
||||
1
|
||||
valid 123451
|
||||
1
|
||||
valid 1234567890120
|
||||
1
|
||||
valid 2369
|
||||
0
|
||||
valid 123459
|
||||
0
|
||||
valid 1234567890129
|
||||
0
|
||||
traceverhoeff 2363
|
||||
cᵢ│p[i,nᵢ]│i│nᵢ│n│cₒ│
|
||||
──┼───────┼─┼──┼─┼──┤
|
||||
3 │3 │0│0 │3│0 │
|
||||
1 │3 │1│1 │6│3 │
|
||||
4 │3 │2│2 │3│1 │
|
||||
0 │1 │3│3 │2│4 │
|
||||
traceverhoeff 123451
|
||||
cᵢ│p[i,nᵢ]│i│nᵢ│n│cₒ│
|
||||
──┼───────┼─┼──┼─┼──┤
|
||||
1 │1 │0│0 │1│0 │
|
||||
9 │8 │1│1 │5│1 │
|
||||
2 │7 │2│2 │4│9 │
|
||||
8 │6 │3│3 │3│2 │
|
||||
3 │5 │4│4 │2│8 │
|
||||
0 │2 │5│5 │1│3 │
|
||||
Loading…
Add table
Add a link
Reference in a new issue