ISBN2 by nn

BEGIN{FS=_}d=11-NF%2{for(v=n=-1;v%d&&n++<10;)for(v=a[i=4];c=_$++i;)v+=(d%2?15-i:i%2?1:3)*(c>9?c>"?"?10:n:c)}sub(/\?/,n>9?"X":n)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top