ISBN2 by nn

println"$System.in".tokenize().sum{l->n=l[4..-1].grep{1}
for(j=0;(l.size()%7?{x->i=0;n.sum{(it-'?'?(int)it-48:x)*(i++%2?3:1)}%10}:{x->i=10;n.sum{(it-'?'?it-'X'?(int)it-48:10:x)*i--}%11})(j);)j++
l.replace('?',''+j)+'\n'}

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

download

return to the top page